rust-analyzer: thread '' panicked at 'index out of bounds: the len is 1 but the index is 1', crates/hir_def/src/nameres/path_resolution.rs:385:33

[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[Info  - 11:51:32] Connection to server got closed. Server will restart.
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
[ERROR project_model::workspace] cyclic deps: rustc_std_workspace_core(CrateId(1187)) -> core(CrateId(188)), alternative path: core(CrateId(188)) -> rand(CrateId(1055)) -> getrandom(CrateId(529)) -> cfg_if(CrateId(147)) -> compiler_builtins(CrateId(181)) -> rustc_std_workspace_core(CrateId(1187))
Panic context:
> 
version: d15f646ff 2021-08-30 stable
request: textDocument/hover HoverParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/bjorn/Projects/rust/compiler/rustc_hir_pretty/src/lib.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 83,
            character: 16,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', crates/hir_def/src/nameres/path_resolution.rs:385:33
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:92:14
   2: core::panicking::panic_bounds_check
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:69:5
   3: hir_def::nameres::path_resolution::<impl hir_def::nameres::DefMap>::resolve_path_fp_with_macro_single
   4: hir_def::resolver::Resolver::resolve_path_in_type_ns
   5: hir_ty::lower::TyLoweringContext::lower_trait_ref_from_path
   6: hir_ty::lower::impl_trait_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  11: salsa::derived::slot::MemoRevisions::validate_memoized_value
  12: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  13: salsa::derived::slot::Slot<Q,MP>::read
  14: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  15: <DB as hir_ty::db::HirDatabase>::trait_impls_in_crate
  16: hir::Impl::all_for_type
  17: ide::goto_implementation::goto_implementation
  18: std::panicking::try
  19: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  20: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  21: rust_analyzer::handlers::handle_hover
  22: rust_analyzer::dispatch::RequestDispatcher::on::{{closure}}::{{closure}}
  23: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 12:20:13] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 1
  Code: -32603 

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 27
  • Comments: 55 (40 by maintainers)

Commits related to this issue

Most upvoted comments

I have investigated this issue further and it does indeed look like a bug in salsa’s interning code. Updating salsa to include https://github.com/salsa-rs/salsa/commit/f7dd6b3219b25a5cdc1ab09c94574a8c2432bbb7 does no longer trigger my assertions and should hopefully fix this issue too.

Yeah, I’ve looked at the code in hir_def and couldn’t find anything that looked wrong (most APIs in there make it very hard to mismatch IDs like that).

It looks to me like something outside of hir_def is causing the problem. Almost as if the data interned in the salsa database gets corrupted or mixed up somehow.

It was a git repo, with only main.
latest version of rust, rust-analyzer.

Switched to pre-release

Error
Panic context:
> 
version: 0.4.1415-standalone (f5401f620 2023-02-24)
request: textDocument/completion CompletionParams {
    text_document_position: TextDocumentPositionParams {
        text_document: TextDocumentIdentifier {
            uri: Url {
                scheme: "file",
                cannot_be_a_base: false,
                username: "",
                password: None,
                host: None,
                port: None,
                path: "/Users/grishy/projects/grishy/qunshine/src/main.rs",
                query: None,
                fragment: None,
            },
        },
        position: Position {
            line: 14,
            character: 6,
        },
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
    context: Some(
        CompletionContext {
            trigger_kind: TriggerCharacter,
            trigger_character: Some(
                ".",
            ),
        },
    ),
}

> collect_items MacroCall: impl_to_primitive_int_to_int!{isize:fnto_isize->isize;fnto_i8->i8;fnto_i16->i16;fnto_i32->i32;fnto_i64->i64;#[cfg(has_i128)]fnto_i128->i128;}

> DefMap CrateId(41) crate_name=Some(CrateDisplayName { crate_name: CrateName("malloc_buf"), canonical_name: "malloc_buf" }) block=None path=impl_to_primitive_int_to_int

thread 'Worker' panicked at 'index out of bounds: the len is 1 but the index is 3', crates/hir-def/src/nameres/path_resolution.rs:388:33
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: hir_def::nameres::path_resolution::<impl hir_def::nameres::DefMap>::resolve_path_fp_with_macro_single
   4: hir_def::nameres::path_resolution::<impl hir_def::nameres::DefMap>::resolve_path_fp_with_macro
   5: <hir_expand::InFile<&syntax::ast::generated::nodes::MacroCall> as hir_def::AsMacroCall>::as_call_id_with_errors
   6: hir_def::body::Expander::enter_expand
   7: hir_def::data::AssocItemCollector::collect
   8: hir_def::data::ImplData::impl_data_with_diagnostics_query
   9: salsa::runtime::Runtime::execute_query_implementation
  10: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  11: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  12: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  13: salsa::derived::slot::MemoRevisions::validate_memoized_value
  14: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  15: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  16: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  17: salsa::derived::slot::MemoRevisions::validate_memoized_value
  18: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  19: salsa::derived::slot::Slot<Q,MP>::read
  20: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  21: <DB as hir_ty::db::HirDatabase>::inherent_impls_in_crate::__shim
  22: hir_ty::method_resolution::incoherent_inherent_impl_crates
  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::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  27: <DB as hir_ty::db::HirDatabase>::incoherent_inherent_impl_crates::__shim
  28: <DB as hir_ty::db::HirDatabase>::incoherent_inherent_impl_crates
  29: hir_ty::method_resolution::def_crates
  30: hir_ty::method_resolution::iterate_inherent_methods
  31: hir_ty::method_resolution::iterate_method_candidates_by_receiver
  32: hir_ty::method_resolution::iterate_method_candidates_dyn
  33: hir::Type::iterate_method_candidates_dyn
  34: hir::Type::iterate_method_candidates
  35: ide_db::imports::import_assets::trait_applicable_items
  36: ide_db::imports::import_assets::ImportAssets::search_for
  37: ide_db::imports::import_assets::ImportAssets::search_for_imports
  38: ide_completion::completions::flyimport::import_on_the_fly_dot
  39: ide_completion::completions::complete_name_ref
  40: ide_completion::completions
  41: std::panicking::try
  42: rust_analyzer::handlers::handle_completion
  43: std::panicking::try
  44: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 21:37:28] Request textDocument/completion failed.
  Message: request handler panicked: index out of bounds: the len is 1 but the index is 3
  Code: -32603 

But it’s OK if I create a new repo… image

To give a short update on this: I think I roughly know what’s happening now, and I’ve posted my findings on the salsa Zulip, where I hope we’ll figure out what the intended behavior of salsa is, and how to prevent similar bugs in the future (since this was quite the nightmare to debug).

Out of curiosiosity, but does everyone here who ran into this issue before this monday have rust-analyzer.experimental.procAttrMacros enabled? For the people that have had this happen since this tuesday, are you running the nightly rust analyzer version?

I can’t shake the feeling for some reason that this is attribute macro related so I wanna confirm this.

I have rust-analyzer.procMacro.enable enabled and rust-analyzer.experimental.procAttrMacros disabled.

Just checked and I was on the stable channel.

Got the panic again, dump:

Panic context:
> 
version: b73b32147 2021-09-06 dev
request: textDocument/hover HoverParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/jplatte/code/ruma/crates/ruma-state-res/src/lib.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 648,
            character: 28,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> trait_data_query(TraitId(333) -> ItemLoc { container: ModuleId { krate: CrateId(791), block: None, local_id: Idx::<ModuleData>(5) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(3696))), block: None }, value: Idx::<Trait>(4) } } -> Trait { name: Name(Text("Deserializer")), visibility: RawVisibilityId("pub"), generic_params: GenericParams { types: Arena { len: 1, data: [TypeParamData { name: Some(Name(Text("Self"))), default: None, provenance: TraitSelf }] }, lifetimes: Arena { len: 1, data: [LifetimeParamData { name: Name(Text("'de")) }] }, consts: Arena { len: 0, data: [] }, where_predicates: [TypeBound { target: TypeRef(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] })), bound: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Sized"))] }, generic_args: [None] }, None) }] }, is_auto: false, is_unsafe: false, items: [TypeAlias(Idx::<TypeAlias>(2)), Function(Idx::<Function>(9)), Function(Idx::<Function>(10)), Function(Idx::<Function>(11)), Function(Idx::<Function>(12)), Function(Idx::<Function>(13)), Function(Idx::<Function>(14)), MacroCall(Idx::<MacroCall>(19)), Function(Idx::<Function>(15)), Function(Idx::<Function>(16)), Function(Idx::<Function>(17)), Function(Idx::<Function>(18)), MacroCall(Idx::<MacroCall>(20)), Function(Idx::<Function>(19)), Function(Idx::<Function>(20)), Function(Idx::<Function>(21)), Function(Idx::<Function>(22)), Function(Idx::<Function>(23)), Function(Idx::<Function>(24)), Function(Idx::<Function>(25)), Function(Idx::<Function>(26)), Function(Idx::<Function>(27)), Function(Idx::<Function>(28)), Function(Idx::<Function>(29)), Function(Idx::<Function>(30)), Function(Idx::<Function>(31)), Function(Idx::<Function>(32)), Function(Idx::<Function>(33)), Function(Idx::<Function>(34)), Function(Idx::<Function>(35)), Function(Idx::<Function>(36)), Function(Idx::<Function>(37)), Function(Idx::<Function>(38))], ast_id: FileAstId::<syntax::ast::generated::nodes::Trait>(22) })

> collect_items MacroCall: serde_if_integer128! {
        /// Hint that the `Deserialize` type is expecting an `i128` value.
        ///
        /// This method is available only on Rust compiler versions >=1.26. The
        /// default behavior unconditionally returns an error.
        fn deserialize_i128<V>(self, visitor: V) -> Result<V::Value, Self::Error>
        where
            V: Visitor<'de>
        {
            let _ = visitor;
            Err(Error::custom("i128 is not supported"))
        }
    }

> DefMap CrateId(791) crate_name=Some(CrateDisplayName { crate_name: CrateName("build_script_build"), canonical_name: "build-script-build" }) block=None path=serde_if_integer128

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 5', crates/hir_def/src/nameres/path_resolution.rs:395:33
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: b73b32147 2021-09-06 dev
request: textDocument/hover HoverParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/jplatte/code/ruma/crates/ruma-state-res/src/lib.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 258,
            character: 19,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> impl_trait_query(ImplId(20813) -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Codec"))] }, generic_args: [None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("AlertMessagePayload"))] }, generic_args: [None] }), items: [FunctionId(FunctionId(75933)), FunctionId(FunctionId(75934))], is_negative: false })

> DefMap CrateId(753) crate_name=Some(CrateDisplayName { crate_name: CrateName("bench"), canonical_name: "bench" }) block=None path=AlertMessagePayload

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 3', crates/hir_def/src/nameres/path_resolution.rs:395:33
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: b73b32147 2021-09-06 dev
request: textDocument/hover HoverParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/jplatte/code/ruma/crates/ruma-state-res/src/lib.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 57,
            character: 23,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> impl_trait_query(ImplId(20813) -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Codec"))] }, generic_args: [None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("AlertMessagePayload"))] }, generic_args: [None] }), items: [FunctionId(FunctionId(75933)), FunctionId(FunctionId(75934))], is_negative: false })

> DefMap CrateId(753) crate_name=Some(CrateDisplayName { crate_name: CrateName("bench"), canonical_name: "bench" }) block=None path=AlertMessagePayload

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 3', crates/hir_def/src/nameres/path_resolution.rs:395:33
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 00:49:21] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 3
  Code: -32603 
Panic context:
> 
version: b73b32147 2021-09-06 dev
request: textDocument/hover HoverParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/jplatte/code/ruma/crates/ruma-state-res/src/lib.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 62,
            character: 28,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> impl_trait_query(ImplId(20813) -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Codec"))] }, generic_args: [None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("AlertMessagePayload"))] }, generic_args: [None] }), items: [FunctionId(FunctionId(75933)), FunctionId(FunctionId(75934))], is_negative: false })

> DefMap CrateId(753) crate_name=Some(CrateDisplayName { crate_name: CrateName("bench"), canonical_name: "bench" }) block=None path=AlertMessagePayload

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 3', crates/hir_def/src/nameres/path_resolution.rs:395:33
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 00:50:59] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 3
  Code: -32603 
Panic context:
> 
version: b73b32147 2021-09-06 dev
request: textDocument/hover HoverParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/jplatte/code/ruma/crates/ruma-state-res/src/lib.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 56,
            character: 32,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> impl_trait_query(ImplId(20813) -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Codec"))] }, generic_args: [None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("AlertMessagePayload"))] }, generic_args: [None] }), items: [FunctionId(FunctionId(75933)), FunctionId(FunctionId(75934))], is_negative: false })

> DefMap CrateId(753) crate_name=Some(CrateDisplayName { crate_name: CrateName("bench"), canonical_name: "bench" }) block=None path=AlertMessagePayload

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 3', crates/hir_def/src/nameres/path_resolution.rs:395:33
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: b73b32147 2021-09-06 dev
request: textDocument/hover HoverParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/jplatte/code/ruma/crates/ruma-state-res/src/lib.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 61,
            character: 25,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> impl_trait_query(ImplId(20813) -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Codec"))] }, generic_args: [None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("AlertMessagePayload"))] }, generic_args: [None] }), items: [FunctionId(FunctionId(75933)), FunctionId(FunctionId(75934))], is_negative: false })

> DefMap CrateId(753) crate_name=Some(CrateDisplayName { crate_name: CrateName("bench"), canonical_name: "bench" }) block=None path=AlertMessagePayload

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 3', crates/hir_def/src/nameres/path_resolution.rs:395:33
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 01:27:22] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 3
  Code: -32603 

Repo at or right after the crash: https://github.com/ruma/ruma/tree/ra-panic-2021-09-12

I’ve added some more logging in #10159, so please post another panic message when you encounter this again

Just ran into this while hacking on salsa:

Panic context:
> 
version: 726f34cb4 2021-09-03 dev
request: textDocument/hover HoverParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/jonas/dev/salsa/tests/on_demand_inputs.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 24,
            character: 26,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> DefMap CrateId(153) None path Ident

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 3', crates/hir_def/src/nameres/path_resolution.rs:394:33

And managed to reproduce this once by hovering over Ident here, but a subsequent server restart made it no longer reproduce…

I have no idea why hovering over anything in on_demand_inputs.rs would make us try to resolve Ident though.