rust-analyzer: Rust analyser panicked in VSC

rust-analyzer version: 5fae65dd2 2022-03-07 stable

rustc version: rustc 1.61.0-nightly (03918badd 2022-03-07)

relevant settings:

VSC version

Version: 1.65.0
Commit: b5205cc8eb4fbaa726835538cd82372cc0222d43
Date: 2022-03-02T11:12:36.248Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Linux x64 5.16.12-200.fc35.x86_64

Error dump as displayed

Panic context:
> 
version: 5fae65dd2 2022-03-07 stable
request: textDocument/semanticTokens/full SemanticTokensParams {
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/martin/git/hypoboleus/engine/src/store.rs",
            query: None,
            fragment: None,
        },
    },
}

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.76.0/src/fold/subst.rs:60:19
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
   2: core::panicking::panic_bounds_check
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:84:5
   3: <chalk_ir::fold::subst::Subst<I> as chalk_ir::fold::Folder<I>>::fold_free_var_ty
   4: <chalk_ir::Ty<I> as chalk_ir::fold::SuperFold<I>>::super_fold_with
   5: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::GenericArg<I>>::fold_with
   6: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   7: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Substitution<I>>::fold_with
   8: chalk_ir::_::<impl chalk_ir::fold::Fold<I> for chalk_ir::WhereClause<I>>::fold_with
   9: chalk_ir::fold::binder_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Binders<T>>::fold_with
  10: chalk_ir::Binders<T>::substitute
  11: hir_ty::chalk_db::convert_where_clauses
  12: hir_ty::chalk_db::struct_datum_query
  13: salsa::runtime::Runtime::execute_query_implementation
  14: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  15: salsa::derived::slot::Slot<Q,MP>::read
  16: salsa::QueryTable<Q>::get
  17: <DB as hir_ty::db::HirDatabase>::struct_datum
  18: chalk_solve::clauses::program_clauses_that_could_match
  19: chalk_recursive::solve::SolveIteration::solve_iteration
  20: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  21: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_root_goal
  22: <hir_ty::db::TraitSolveQueryQuery as salsa::plumbing::QueryFunction>::execute
  23: salsa::runtime::Runtime::execute_query_implementation
  24: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  25: salsa::derived::slot::Slot<Q,MP>::read
  26: salsa::QueryTable<Q>::get
  27: <DB as hir_ty::db::HirDatabase>::trait_solve_query
  28: hir_ty::db::trait_solve_wait
  29: <DB as hir_ty::db::HirDatabase>::trait_solve
  30: hir_ty::infer::unify::InferenceTable::try_obligation
  31: hir_ty::autoderef::autoderef_step
  32: <hir_ty::autoderef::Autoderef as core::iter::traits::iterator::Iterator>::next
  33: hir_ty::method_resolution::autoderef_method_receiver
  34: hir_ty::method_resolution::iterate_method_candidates_dyn
  35: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  36: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  37: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr
  38: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  39: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::check_call_arguments
  40: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  41: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  42: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  43: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  44: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  45: hir_ty::infer::infer_query
  46: salsa::runtime::Runtime::execute_query_implementation
  47: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  48: salsa::derived::slot::Slot<Q,MP>::read
  49: salsa::QueryTable<Q>::get
  50: <DB as hir_ty::db::HirDatabase>::infer_query
  51: hir_ty::db::infer_wait
  52: hir::Local::ty
  53: ide::syntax_highlighting::highlight::highlight_def
  54: ide::syntax_highlighting::highlight::name_like
  55: ide::syntax_highlighting::highlight
  56: std::panicking::try
  57: rust_analyzer::handlers::handle_semantic_tokens_full
  58: std::panicking::try
  59: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: 5fae65dd2 2022-03-07 stable
request: rust-analyzer/inlayHints InlayHintsParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/martin/git/hypoboleus/engine/src/store.rs",
            query: None,
            fragment: None,
        },
    },
}

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.76.0/src/fold/subst.rs:60:19
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
   2: core::panicking::panic_bounds_check
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:84:5
   3: <chalk_ir::fold::subst::Subst<I> as chalk_ir::fold::Folder<I>>::fold_free_var_ty
   4: <chalk_ir::Ty<I> as chalk_ir::fold::SuperFold<I>>::super_fold_with
   5: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::GenericArg<I>>::fold_with
   6: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   7: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Substitution<I>>::fold_with
   8: chalk_ir::_::<impl chalk_ir::fold::Fold<I> for chalk_ir::WhereClause<I>>::fold_with
   9: chalk_ir::fold::binder_impls::<impl chalk_ir::fold::Fold<I> for[Error - 18:23:18] Request textDocument/semanticTokens/full failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 1
  Code: -32603 
 chalk_ir::Binders<T>>::fold_with
  10: chalk_ir::Binders<T>::substitute
  11: hir_ty::chalk_db::convert_where_clauses
  12: hir_ty::chalk_db::struct_datum_query
  13: salsa::runtime::Runtime::execute_query_implementation
  14: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  15: salsa::derived::slot::Slot<Q,MP>::read
  16: salsa::QueryTable<Q>::get
  17: <DB as hir_ty::db::HirDatabase>::struct_datum
  18: chalk_solve::clauses::program_clauses_that_could_match
  19: chalk_recursive::solve::SolveIteration::solve_iteration
  20: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  21: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_root_goal
  22: <hir_ty::db::TraitSolveQueryQuery as salsa::plumbing::QueryFunction>::execute
  23: salsa::runtime::Runtime::execute_query_implementation
  24: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  25: salsa::derived::slot::Slot<Q,MP>::read
  26: salsa::QueryTable<Q>::get
  27: <DB as hir_ty::db::HirDatabase>::trait_solve_query
  28: hir_ty::db::trait_solve_wait
  29: <DB as hir_ty::db::HirDatabase>::trait_solve
  30: hir_ty::infer::unify::InferenceTable::try_obligation
  31: hir_ty::autoderef::autoderef_step
  32: <hir_ty::autoderef::Autoderef as core::iter::traits::iterator::Iterator>::next
  33: hir_ty::method_resolution::autoderef_method_receiver
  34: hir_ty::method_resolution::iterate_method_candidates_dyn
  35: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  36: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  37: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr
  38: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  39: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::check_call_arguments
  40: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  41: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  42: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  43: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  44: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  45: hir_ty::infer::infer_query
  46: salsa::runtime::Runtime::execute_query_implementation
  47: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  48: salsa::derived::slot::Slot<Q,MP>::read
  49: salsa::QueryTable<Q>::get
  50: <DB as hir_ty::db::HirDatabase>::infer_query
  51: hir_ty::db::infer_wait
  52: hir::source_analyzer::SourceAnalyzer::new_for_body
  53: hir::semantics::SemanticsImpl::analyze_impl
  54: ide::inlay_hints::inlay_hints
  55: std::panicking::try
  56: rust_analyzer::handlers::handle_inlay_hints
  57: std::panicking::try
  58: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.76.0/src/fold/subst.rs:60:19
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
   2: core::panicking::panic_bounds_check
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:84:5
   3: <chalk_ir::fold::subst::Subst<I> as chalk_ir::fold::Folder<I>>::fold_free_var_ty
   4: <chalk_ir::Ty<I> as chalk_ir::fold::SuperFold<I>>::super_fold_with
   5: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::GenericArg<I>>::fold_with
   6: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   7: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Substitution<I>>::fold_with
   8: chalk_ir::_::<impl chalk_ir::fold::Fold<I> for chalk_ir::WhereClause<I>>::fold_with
   9: chalk_ir::fold::binder_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Binders<T>>::fold_with
  10: chalk_ir::Binders<T>::substitute
  11: hir_ty::chalk_db::convert_where_clauses
  12: hir_ty::chalk_db::struct_datum_query
  13: salsa::runtime::Runtime::execute_query_implementation
  14: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  15: salsa::derived::slot::Slot<Q,MP>::read
  16: salsa::QueryTable<Q>::get
  17: <DB as hir_ty::db::HirDatabase>::struct_datum
  18: chalk_solve::clauses::program_clauses_that_could_match
  19: chalk_recursive::solve::SolveIteration::solve_iteration
  20: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  21: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_root_goal
  22: <hir_ty::db::TraitSolveQueryQuery as salsa::plumbing::QueryFunction>::execute
  23: salsa::runtime::Runtime::execute_query_implementation
  24: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  25: salsa::derived::slot::Slot<Q,MP>::read
  26: salsa::QueryTable<Q>::get
  27: <DB as hir_ty::db::HirDatabase>::trait_solve_query
  28: hir_ty::db::trait_solve_wait
  29: <DB as hir_ty::db::HirDatabase>::trait_solve
  30: hir_ty::infer::unify::InferenceTable::try_obligation
  31: hir_ty::autoderef::autoderef_step
  32: <hir_ty::autoderef::Autoderef as core::iter::traits::iterator::Iterator>::next
  33: hir_ty::method_resolution::autoderef_method_receiver
  34: hir_ty::method_resolution::iterate_method_candidates_dyn
  35: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  36: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  37: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr
  38: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  39: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::check_call_arguments
  40: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  41: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  42: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  43: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  44: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  45: hir_ty::infer::infer_query
  46: salsa::runtime::Runtime::execute_query_implementation
  47: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  48: salsa::derived::slot::Slot<Q,MP>::read
  49: salsa::QueryTable<Q>::get
  50: <DB as hir_ty::db::HirDatabase>::infer_query
  51: hir_ty::db::infer_wait
  52: hir::DefWithBody::diagnostics
  53: hir::Module::diagnostics
  54: ide_diagnostics::diagnostics
  55: std::panicking::try
  56: ide::Analysis::diagnostics
  57: rust_analyzer::handlers::publish_diagnostics
  58: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  59: alloc::vec::source_iter_marker::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
  60: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: 5fae65dd2 2022-03-07 stable
request: rust-analyzer/inlayHints InlayHintsParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/martin/git/hypoboleus/engine/src/store.rs",
            query: None,
            fragment: None,
        },
    },
}

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.76.0/src/fold/subst.rs:60:19
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
   2: core::panicking::panic_bounds_check
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:84:5
   3: <chalk_ir::fold::subst::Subst<I> as chalk_ir::fold::Folder<I>>::fold_free_var_ty
   4: <chalk_ir::Ty<I> as chalk_ir::fold::SuperFold<I>>::super_fold_with
   5: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::GenericArg<I>>::fold_with
   6: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   7: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Substitution<I>>::fold_with
   8: chalk_ir::_::<impl chalk_ir::fold::Fold<I> for chalk_ir::WhereClause<I>>::fold_with
   9: chalk_ir::fold::binder_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Binders<T>>::fold_with
  10: chalk_ir::Binders<T>::substitute
  11: hir_ty::chalk_db::convert_where_clauses
  12: hir_ty::chalk_db::struct_datum_query
  13: salsa::runtime::Runtime::execute_query_implementation
  14: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  15: salsa::derived::slot::Slot<Q,MP>::read
  16: salsa::QueryTable<Q>::get
  17: <DB as hir_ty::db::HirDatabase>::struct_datum
  18: chalk_solve::clauses::program_clauses_that_could_match
  19: chalk_recursive::solve::SolveIteration::solve_iteration
  20: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  21: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_root_goal
  22: <hir_ty::db::TraitSolveQueryQuery as salsa::plumbing::QueryFunction>::execute
  23: salsa::runtime::Runtime::execute_query_implementation
  24: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  25: salsa::derived::slot::Slot<Q,MP>::read
  26: salsa::QueryTable<Q>::get
  27: <DB as hir_ty::db::HirDatabase>::trait_solve_query
  28: hir_ty::db::trait_solve_wait
  29: <DB as hir_ty::db::HirDatabase>::trait_solve
  30: hir_ty::infer::unify::InferenceTable::try_obligation
  31: hir_ty::autoderef::autoderef_step
  32: <hir_ty::autoderef::Autoderef as core::iter::traits::iterator::Iterator>::next
  33: hir_ty::method_resolution::autoderef_method_receiver
  34: hir_ty::method_resolution::iterate_method_candidates_dyn
  35: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  36: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  37: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr
  38: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  39: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::check_call_arguments
  40: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  41: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  42: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  43: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  44: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  45: hir_ty::infer::infer_query
  46: salsa::runtime::Runtime::execute_query_implementation
  47: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  48: salsa::derived::slot::Slot<Q,MP>::read
  49: salsa::QueryTable<Q>::get
  50: <DB as hir_ty::db::HirDatabase>::infer_query
  51: hir_ty::db::infer_wait
  52: hir::source_analyzer::SourceAnalyzer::new_for_body
  53: hir::semantics::SemanticsImpl::analyze_impl
  54: ide::inlay_hints::inlay_hints
  55: std::panicking::try
  56: rust_analyzer::handlers::handle_inlay_hints
  57: std::panicking::try
  58: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: 5fae65dd2 2022-03-07 stable
request: rust-analyzer/inlayHints InlayHintsParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/martin/git/hypoboleus/engine/src/store.rs",
            query: None,
            fragment: None,
        },
    },
}

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.76.0/src/fold/subst.rs:60:19
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
   2: core::panicking::panic_bounds_check
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:84:5
   3: <chalk_ir::fold::subst::Subst<I> as chalk_ir::fold::Folder<I>>::fold_free_var_ty
   4: <chalk_ir::Ty<I> as chalk_ir::fold::SuperFold<I>>::super_fold_with
   5: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::GenericArg<I>>::fold_with
   6: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   7: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Substitution<I>>::fold_with
   8: chalk_ir::_::<impl chalk_ir::fold::Fold<I> for chalk_ir::WhereClause<I>>::fold_with
   9: chalk_ir::fold::binder_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Binders<T>>::fold_with
  10: chalk_ir::Binders<T>::substitute
  11: hir_ty::chalk_db::convert_where_clauses
  12: hir_ty::chalk_db::struct_datum_query
  13: salsa::runtime::Runtime::execute_query_implementation
  14: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  15: salsa::derived::slot::Slot<Q,MP>::read
  16: salsa::QueryTable<Q>::get
  17: <DB as hir_ty::db::HirDatabase>::struct_datum
  18: chalk_solve::clauses::program_clauses_that_could_match
  19: chalk_recursive::solve::SolveIteration::solve_iteration
  20: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  21: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_root_goal
  22: <hir_ty::db::TraitSolveQueryQuery as salsa::plumbing::QueryFunction>::execute
  23: salsa::runtime::Runtime::execute_query_implementation
  24: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  25: salsa::derived::slot::Slot<Q,MP>::read
  26: salsa::QueryTable<Q>::get
  27: <DB as hir_ty::db::HirDatabase>::trait_solve_query
  28: hir_ty::db::trait_solve_wait
  29: <DB as hir_ty::db::HirDatabase>::trait_solve
  30: hir_ty::infer::unify::InferenceTable::try_obligation
  31: hir_ty::autoderef::autoderef_step
  32: <hir_ty::autoderef::Autoderef as core::iter::traits::iterator::Iterator>::next
  33: hir_ty::method_resolution::autoderef_method_receiver
  34: hir_ty::method_resolution::iterate_method_candidates_dyn
  35: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  36: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  37: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr
  38: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  39: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::check_call_arguments
  40: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  41: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  42: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  43: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  44: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  45: hir_ty::infer::infer_query
  46: salsa::runtime::Runtime::execute_query_implementation
  47: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  48: salsa::derived::slot::Slot<Q,MP>::read
  49: salsa::QueryTable<Q>::get
  50: <DB as hir_ty::db::HirDatabase>::infer_query
  51: hir_ty::db::infer_wait
  52: hir::source_analyzer::SourceAnalyzer::new_for_body
  53: hir::semantics::SemanticsImpl::analyze_impl
  54: ide::inlay_hints::inlay_hints
  55: std::panicking::try
  56: rust_analyzer::handlers::handle_inlay_hints
  57: std::panicking::try
  58: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: 5fae65dd2 2022-03-07 stable
request: textDocument/semanticTokens/range SemanticTokensRangeParams {
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/martin/git/hypoboleus/engine/src/store.rs",
            query: None,
            fragment: None,
        },
    },
    range: Range {
        start: Position {
            line: 23,
            character: 0,
        },
        end: Position {
            line: 207,
            character: 18,
        },
    },
}

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.76.0/src/fold/subst.rs:60:19
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
   2: core::panicking::panic_bounds_check
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:84:5
   3: <chalk_ir::fold::subst::Subst<I> as chalk_ir::fold::Folder<I>>::fold_free_var_ty
   4: <chalk_ir::Ty<I> as chalk_ir::fold::SuperFold<I>>::super_fold_with
   5: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::GenericArg<I>>::fold_with
   6: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   7: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Substitution<I>>::fold_with
   8: chalk_ir::_::<impl chalk_ir::fold::Fold<I> for chalk_ir::WhereClause<I>>::fold_with
   9: chalk_ir::fold::binder_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Binders<T>>::fold_with
  10: chalk_ir::Binders<T>::substitute
  11: hir_ty::chalk_db::convert_where_clauses
  12: hir_ty::chalk_db::struct_datum_query
  13: salsa::runtime::Runtime::execute_query_implementation
  14: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  15: salsa::derived::slot::Slot<Q,MP>::read
  16: salsa::QueryTable<Q>::get
  17: <DB as hir_ty::db::HirDatabase>::struct_datum
  18: chalk_solve::clauses::program_clauses_that_could_match
  19: chalk_recursive::solve::SolveIteration::solve_iteration
  20: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  21: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_root_goal
  22: <hir_ty::db::TraitSolveQueryQuery as salsa::plumbing::QueryFunction>::execute
  23: salsa::runtime::Runtime::execute_query_implementation
  24: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  25: salsa::derived::slot::Slot<Q,MP>::read
  26: salsa::QueryTable<Q>::get
  27: <DB as hir_ty::db::HirDatabase>::trait_solve_query
  28: hir_ty::db::trait_solve_wait
  29: <DB as hir_ty::db::HirDatabase>::trait_solve
  30: hir_ty::infer::unify::InferenceTable::try_obligation
  31: hir_ty::autoderef::autoderef_step
  32: <hir_ty::autoderef::Autoderef as core::iter::traits::iterator::Iterator>::next
  33: hir_ty::method_resolution::autoderef_method_receiver
  34: hir_ty::method_resolution::iterate_method_candidates_dyn
  35: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  36: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  37: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr
  38: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  39: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::check_call_arguments
  40: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  41: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  42: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  43: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  44: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  45: hir_ty::infer::infer_query
  46: salsa::runtime::Runtime::execute_query_implementation
  47: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  48: salsa::derived::slot::Slot<Q,MP>::read
  49: salsa::QueryTable<Q>::get
  50: <DB as hir_ty::db::HirDatabase>::infer_query
  51: hir_ty::db::infer_wait
  52: hir::Local::ty
  53: ide::syntax_highlighting::highlight::highlight_def
  54: ide::syntax_highlighting::highlight::name_like
  55: ide::syntax_highlighting::highlight
  56: std::panicking::try
  57: rust_analyzer::handlers::handle_semantic_tokens_range
  58: std::panicking::try
  59: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 18:23:19] Request textDocument/semanticTokens/range failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 1
  Code: -32603 
Panic context:
> 
version: 5fae65dd2 2022-03-07 stable
request: rust-analyzer/inlayHints InlayHintsParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/martin/git/hypoboleus/engine/src/store.rs",
            query: None,
            fragment: None,
        },
    },
}

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.76.0/src/fold/subst.rs:60:19
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
   2: core::panicking::panic_bounds_check
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:84:5
   3: <chalk_ir::fold::subst::Subst<I> as chalk_ir::fold::Folder<I>>::fold_free_var_ty
   4: <chalk_ir::Ty<I> as chalk_ir::fold::SuperFold<I>>::super_fold_with
   5: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::GenericArg<I>>::fold_with
   6: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   7: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Substitution<I>>::fold_with
   8: chalk_ir::_::<impl chalk_ir::fold::Fold<I> for chalk_ir::WhereClause<I>>::fold_with
   9: chalk_ir::fold::binder_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Binders<T>>::fold_with
  10: chalk_ir::Binders<T>::substitute
  11: hir_ty::chalk_db::convert_where_clauses
  12: hir_ty::chalk_db::struct_datum_query
  13: salsa::runtime::Runtime::execute_query_implementation
  14: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  15: salsa::derived::slot::Slot<Q,MP>::read
  16: salsa::QueryTable<Q>::get
  17: <DB as hir_ty::db::HirDatabase>::struct_datum
  18: chalk_solve::clauses::program_clauses_that_could_match
  19: chalk_recursive::solve::SolveIteration::solve_iteration
  20: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  21: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_root_goal
  22: <hir_ty::db::TraitSolveQueryQuery as salsa::plumbing::QueryFunction>::execute
  23: salsa::runtime::Runtime::execute_query_implementation
  24: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  25: salsa::derived::slot::Slot<Q,MP>::read
  26: salsa::QueryTable<Q>::get
  27: <DB as hir_ty::db::HirDatabase>::trait_solve_query
  28: hir_ty::db::trait_solve_wait
  29: <DB as hir_ty::db::HirDatabase>::trait_solve
  30: hir_ty::infer::unify::InferenceTable::try_obligation
  31: hir_ty::autoderef::autoderef_step
  32: <hir_ty::autoderef::Autoderef as core::iter::traits::iterator::Iterator>::next
  33: hir_ty::method_resolution::autoderef_method_receiver
  34: hir_ty::method_resolution::iterate_method_candidates_dyn
  35: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  36: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  37: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr
  38: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  39: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::check_call_arguments
  40: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  41: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  42: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  43: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  44: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  45: hir_ty::infer::infer_query
  46: salsa::runtime::Runtime::execute_query_implementation
  47: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  48: salsa::derived::slot::Slot<Q,MP>::read
  49: salsa::QueryTable<Q>::get
  50: <DB as hir_ty::db::HirDatabase>::infer_query
  51: hir_ty::db::infer_wait
  52: hir::source_analyzer::SourceAnalyzer::new_for_body
  53: hir::semantics::SemanticsImpl::analyze_impl
  54: ide::inlay_hints::inlay_hints
  55: std::panicking::try
  56: rust_analyzer::handlers::handle_inlay_hints
  57: std::panicking::try
  58: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 18:36:56] Request textDocument/hover failed.
  Message: Invalid offset
  Code: -32603 

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (10 by maintainers)

Commits related to this issue

Most upvoted comments

wow, you guys are amazing — I was just wondering how to minimise and report and then I found this and tonight’s build fixes the issue

works for me now thanks.

I think I may have found a related crash. Specifically the following code causes the server to crash:

pub struct Vec2;
pub struct CurvePoint;
pub struct Mesh;
pub fn gen_curve<const N: usize>(curve: impl Iterator<Item = CurvePoint>, offsets: [Vec2; N],) -> Mesh {
    todo!()
}

pub fn gen(curve: impl Iterator<Item = CurvePoint>) -> Mesh {
    gen_curve(curve, [Vec2, Vec2, Vec2, Vec2])
}

My best guess is that the server crashes due to placing the Type Generic after the Const Generic (as above), but it may be harder to see, since the type generic is actually created by the impl Iterator parameter. This means that unlike the previous example, the code actually compiles.

EDIT: I’ve tested #11660, and it does also fix the crash for this example.

Regressed by #11140, CC @HKalbasi

The following does crash as a stand-alone; I’ll see if I can shorten it.

#![feature(backtrace, backtrace_frames, try_blocks)]
//#![warn(missing_docs)] suppressed too many messages
/// trace macro for debugging the code in this file
macro_rules! main_trace {
    () => { log::trace!() };
    ($($arg:tt)*) => {
        log::trace!("{} ({}:{})", RGB(0, 235, 215).on(Purple).paint(format!($($arg)*)), std::file!(), std::line!())
    };
}
mod ident;
mod link_base;
mod link_store;
mod linkable;
mod linkbaseserde;
mod linkitem;
mod linkitemserde;
mod linkset;
mod multi;
mod single;
/** `codex_link` supports links between objects.

This crate is used to provide one-to-many and many-to-many links between
objects. Provide an enum `LinkType` which lists the various kinds of link.

Note: the links are implemented by *weak* links. Provide at least one *strong*
link (`LinkableLink`) to each [Linkable] so they are not dropped, for example by
using a [LinkStore] to contain them. */
use std::{
    backtrace::Backtrace,
    cell::RefCell,
    fmt::{Debug, Display, Formatter},
    rc::Rc,
};

//use arr_macro::arr;
use array_init::array_init;
use getset::Getters;
pub use ident::Ident;
pub use linkable::Linkable;
use linkbaseserde::LinkBaseSerde;
use linkitemserde::LinkItemSerde;
use serde::{Deserialize, Serialize};
use thiserror::Error;
extern crate enum_primitive;
use std::{
    iter::Iterator,
    ops::{Index, IndexMut},
};
mod weak_link;
use delegate_attr::delegate;
pub use link_store::LinkStore;
pub use weak_link::LinkableWeakLink;

use crate::link_base::LinkBase;
//use strum::IntoEnumIterator;
//use color_eyre::eyre::Result;
#[cfg(test)]
mod tests;
#[derive(Error, Debug)]
/** errors generated by this crate */
pub enum LinkError {
    #[error("weak link to nowhere")]
    BadWeakLink,
    #[error("link unresolved")]
    UnresolvedLink,
    #[error("ident {0} not found")]
    IdentNotFound(String),
    #[error("deserialize error")]
    SerdeError(#[from] ron::error::Error),
    #[error("cannot upgrade")]
    CannotUpgrade,
    #[error("cannot convert {0} to link type")]
    BadLinkType(usize),
    #[error("link already borrowed")]
    LinkAlreadyBorrowed,
    #[error("internal error: {}", .0)]
    Internal(String),
    #[error("other {:#?}", .backtrace.frames())]
    Other {
        #[from]
        source: eyre::Error,
        backtrace: Backtrace,
    },
}
// --- LinkData ---
/** the data to be linked */
pub trait LinkData<const LINKSIZE: usize>
where
    Self: Clone
        + Serialize
        + for<'a> Deserialize<'a>
        + Default
        + Debug
        + Display
        + From<Self::Serde>
        + Clone
        + Debug
        + Display
        + Serialize
        + for<'a> Deserialize<'a>
        + Default,
    Self::LinkType: Eq
        + PartialEq
        + Ord
        + PartialOrd
        + Copy
        + Debug
        + PartialEq
        + Clone
        + Copy
        + Eq
        + PartialOrd
        + Ord
        + Debug
        + Display
        + Serialize
        + for<'a> Deserialize<'a>
        + Default
        + From<usize>
        + Into<usize>,
    Self::Serde:
        for<'a> Deserialize<'a> + Debug + Serialize + for<'a> Deserialize<'a> + From<Self> + Clone,
{
    type LinkType;
    type Serde;
}
/** results  generated by this crate */
pub type Result<T> = std::result::Result<T, LinkError>;
// --- LinkSerdeOption ---
/** optional [Ident], used for serialising optional [LinkableWeakLink] */
#[derive(Clone, Serialize, Deserialize, Default, Debug)]
pub(crate) struct LinkSerdeOption {
    #[serde(skip_serializing_if = "Option::is_none", default)]
    li: Option<Ident>,
}
// --- LinkSerdeVector ---
/** An `LinkSerdeVector` vector of LinkSerdeOption */
#[derive(Clone, Serialize, Deserialize, Debug)]
#[serde(transparent)]
pub(crate) struct LinkSerdeVector<LT>(Vec<LinkItemSerde<LT>>);
#[delegate(self.0)]
impl<LT> LinkSerdeVector<LT> {
    fn is_empty(&self) -> bool;

    fn iter(&self) -> impl Iterator<Item = &LinkItemSerde<LT>>;
}
impl<LT> Default for LinkSerdeVector<LT> {
    fn default() -> Self { Self(vec![]) }
}
/** An iterator over LinkSerdeVector */
impl<LT> IntoIterator for LinkSerdeVector<LT> {
    type IntoIter = std::vec::IntoIter<Self::Item>;
    type Item = LinkItemSerde<LT>;

    fn into_iter(self) -> Self::IntoIter { self.0.into_iter() }
}
// --- LinkArray ---
/** An `LinkArray` fixed-sized array of Link options */
#[derive(Clone)]
pub(crate) struct LinkArray<const N: usize, LD: LinkData<N>>([LinkableWeakLinkOption<N, LD>; N]);
impl<const N: usize, LD: LinkData<N>> Default for LinkArray<N, LD> {
    fn default() -> Self {
        let defarray = array_init(|_i| LinkableWeakLinkOption::default());
        Self(defarray)
    }
}
impl<const N: usize, LD: LinkData<N>> Index<LD::LinkType> for LinkArray<N, LD> {
    type Output = LinkableWeakLinkOption<N, LD>;

    fn index(&self, link_type: LD::LinkType) -> &Self::Output { self.0.index(link_type.into()) }
}
impl<const N: usize, LD: LinkData<N>> IndexMut<LD::LinkType> for LinkArray<N, LD> {
    fn index_mut(&mut self, link_type: LD::LinkType) -> &mut Self::Output {
        self.0.index_mut(link_type.into())
    }
}
impl<const N: usize, LD: LinkData<N>> Debug for LinkArray<N, LD> {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        for i in 0..N {
            write!(f, "{}: {:?}", LD::LinkType::from(i), self.0[i])?;
            if i != N - 1 {
                write!(f, ", ")?;
            }
        }
        Ok(())
    }
}
// --- LinkableSerde ---
#[derive(Getters, Serialize, Default, Debug, Deserialize)]
/** for (de)serialising [Linkable] */
pub struct LinkableSerde<const N: usize, LD>
where
    LD: LinkData<N>,
{
    #[serde(rename = "d")]
    #[getset(get = "pub")]
    data: LD::Serde,
    #[serde(rename = "l")]
    links: LinkBaseSerde<N, LD::LinkType>,
}
impl<const N: usize, LD: LinkData<N>> From<Linkable<N, LD>> for LinkableSerde<N, LD> {
    fn from(l: Linkable<N, LD>) -> Self {
        Self {
            data: l.data.into(),
            links: l.links.into(),
        }
    }
}
impl<const N: usize, LD: LinkData<N>> LinkableSerde<N, LD> {
    /** `deserialize_to` deserialises a [Linkable], updates the [LinkStore]
     * and returns a [LinkableWeakLink] */
    pub fn deserialize_to<F>(
        data: &str,
        link_store: &mut LinkStore<N, LD>,
        is_selected: F,
    ) -> Result<Option<LinkableWeakLink<N, LD>>>
    where
        F: Fn(&LinkableSerde<N, LD>) -> bool,
    {
        let linkable_serde: Self = ron::de::from_str(data)?;
        if !is_selected(&linkable_serde) {
            return Ok(None);
        }
        let ident = linkable_serde.links.ident();
        let mut weak_link = link_store.ensure(ident, Linkable::<N, LD>::new)?;
        weak_link.deserialize_from(&linkable_serde, link_store)?;
        Ok(Some(weak_link))
    }
}
// --- LinkableLink ---
/** strong link between [Linkable]s */
#[derive(Clone)]
struct LinkableLink<const N: usize, LD: LinkData<N>>(Rc<RefCell<Linkable<N, LD>>>);
impl<const N: usize, LD: LinkData<N>> Debug for LinkableLink<N, LD> {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(f, "->{}", self.0.as_ref().borrow())
    }
}
impl<const N: usize, LD: LinkData<N>> Display for LinkableLink<N, LD> {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(f, ":>{:?}", self.0.as_ref().borrow())
    }
}
#[delegate(self.0.as_ref().borrow())]
impl<const N: usize, LD: LinkData<N>> LinkableLink<N, LD> {
    fn ident(&self) -> Ident;
}
impl<const N: usize, LD: LinkData<N>> LinkableLink<N, LD> {
    fn new(l: Linkable<N, LD>) -> Self { Self(Rc::new(RefCell::new(l))) }

    fn downgrade(&self) -> LinkableWeakLink<N, LD> {
        LinkableWeakLink::<N, LD>::new(Rc::downgrade(&self.0))
    }
}
// --- LinkableWeakLinkOption ---
/** an option of a [LinkableWeakLink] */

#[derive(Clone)]
pub struct LinkableWeakLinkOption<const N: usize, LD: LinkData<N>>(Option<LinkableWeakLink<N, LD>>);
//use std::fmt::{Debug, Display, Formatter};
impl<const N: usize, LD: LinkData<N>> Debug for LinkableWeakLinkOption<N, LD> {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        if let Some(wl) = &self.0 {
            write!(f, "@{:?}", &wl)
        } else {
            write!(f, "(none)")
        }
    }
}
#[delegate(self.0)]
impl<const N: usize, LD: LinkData<N>> LinkableWeakLinkOption<N, LD> {
    fn ok_or_else<E, F>(self, err: F) -> std::result::Result<LinkableWeakLink<N, LD>, E>
    where
        F: FnOnce() -> E;

    fn is_none(&self) -> bool;

    fn is_some(&self) -> bool;
}
impl<const N: usize, LD: LinkData<N>> Default for LinkableWeakLinkOption<N, LD> {
    fn default() -> Self { Self(None) }
}
impl<const N: usize, LD: LinkData<N>> From<LinkableWeakLink<N, LD>>
    for LinkableWeakLinkOption<N, LD>
{
    fn from(link: LinkableWeakLink<N, LD>) -> Self { Self(Some(link)) }
}
impl<const N: usize, LD: LinkData<N>> From<Option<LinkableWeakLink<N, LD>>>
    for LinkableWeakLinkOption<N, LD>
{
    fn from(link_option: Option<LinkableWeakLink<N, LD>>) -> Self { Self(link_option) }
}
impl<const N: usize, LD: LinkData<N>> From<LinkableWeakLinkOption<N, LD>>
    for Option<LinkableWeakLink<N, LD>>
{
    fn from(link_option: LinkableWeakLinkOption<N, LD>) -> Option<LinkableWeakLink<N, LD>> {
        link_option.0
    }
}
impl<const N: usize, LD: LinkData<N>> LinkableWeakLinkOption<N, LD> {
    pub fn inner(self) -> Option<LinkableWeakLink<N, LD>> { self.0 }
}