Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #10084

Closed
Tracked by #10370 ...
bjorn3 opened this issue Aug 30, 2021 · 55 comments · Fixed by #10479
Labels
A-nameres name, path and module resolution Broken Window Bugs / technical debt to be addressed immediately I-panic

Comments

@bjorn3
Copy link
Member

bjorn3 commented Aug 30, 2021

[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 
@jonas-schievink jonas-schievink added A-nameres name, path and module resolution Broken Window Bugs / technical debt to be addressed immediately labels Aug 30, 2021
@jonas-schievink
Copy link
Contributor

According to the trace, this occurred when hovering over the pp::$0Printer part of this line:

https://github.com/rust-lang/rust/blob/13edc17f65bcad7fe9046720a16fc192e810970e/compiler/rustc_hir_pretty/src/lib.rs#L83

That doesn't trigger the panic for me, so there might be local changes that shift the line/column numbers around

@bjorn3
Copy link
Member Author

bjorn3 commented Aug 30, 2021

I suspect I was replacing ast::Attribute with ast::MetaItem.

@matklad
Copy link
Member

matklad commented Aug 30, 2021

@jonas-schievink can we write a better assertion message here? Or maybe add something else to the panic context?

On a meta level, I don't think we will be very successful at reproducing the exact panics the user sees, as that needs in-memory state of the documents, and also the ability to cargo metadata the overall project.

That being said, with our current architecture, I don't think it would be too too hard to add something which dumps all salsa inputs at the moment of the panic into a ~100mb file which gives us a repro. I don't think we should do that due to the privacy concerts though.

So, I'd love us to really be able to look at the panic message, and be able to reverse-engineer the failing input, like in #10083.

@jonas-schievink
Copy link
Contributor

I've opened #10095 to add more debugging info here

bors bot added a commit that referenced this issue Aug 31, 2021
10095: internal: Augment panic context when resolving path r=jonas-schievink a=jonas-schievink

Should help with debugging #10084 and similar issues.

Might have a perf impact since the string is created on every function call.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
bors bot added a commit that referenced this issue Aug 31, 2021
10095: internal: Augment panic context when resolving path r=jonas-schievink a=jonas-schievink

Should help with debugging #10084 and similar issues.

Might have a perf impact since the string is created on every function call.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
@starkat99

This comment has been minimized.

@jonas-schievink

This comment has been minimized.

@jonas-schievink
Copy link
Contributor

jonas-schievink commented Sep 3, 2021

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.

@jplatte
Copy link
Contributor

jplatte commented Sep 5, 2021

I'm currently getting this error a bunch with RA Nightly. Here's a dump of all the output in the VSCode output panel:

Panic context:
> 
version: 5506e0dfa 2021-09-04 nightly
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/state_event.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 29,
            character: 33,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> DefMap CrateId(1069) None path Registry

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:394: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_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: <DB as hir_ty::db::HirDatabase>::impl_self_ty
  12: hir_ty::lower::impl_trait_query
  13: salsa::runtime::Runtime::execute_query_implementation
  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>::trait_impls_in_crate
  22: hir::Impl::all_for_type
  23: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  24: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  25: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  26: ide::goto_implementation::goto_implementation
  27: std::panicking::try
  28: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  29: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  30: rust_analyzer::handlers::handle_hover
  31: std::panicking::try
  32: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 17:59:38] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 1
  Code: -32603 
Panic context:
> 
version: 5506e0dfa 2021-09-04 nightly
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/event_auth.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 23,
            character: 19,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> DefMap CrateId(1069) None path Registry

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:394: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_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: <DB as hir_ty::db::HirDatabase>::impl_self_ty
  12: hir_ty::lower::impl_trait_query
  13: salsa::runtime::Runtime::execute_query_implementation
  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>::trait_impls_in_crate
  22: hir::Impl::all_for_type
  23: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  24: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  25: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  26: ide::goto_implementation::goto_implementation
  27: std::panicking::try
  28: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  29: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  30: rust_analyzer::handlers::handle_hover
  31: std::panicking::try
  32: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 18:00:20] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 1
  Code: -32603 
Panic context:
> 
version: 5506e0dfa 2021-09-04 nightly
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: 446,
            character: 33,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> DefMap CrateId(781) 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:394: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::nameres::path_resolution::<impl hir_def::nameres::DefMap>::resolve_path_fp_with_macro
   5: hir_def::macro_call_as_call_id
   6: <hir_expand::InFile<&syntax::ast::generated::nodes::MacroCall> as hir_def::AsMacroCall>::as_call_id_with_errors
   7: hir_def::body::Expander::enter_expand
   8: hir_def::data::collect_items
   9: hir_def::data::TraitData::trait_data_query
  10: salsa::runtime::Runtime::execute_query_implementation
  11: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  12: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  13: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  14: salsa::derived::slot::MemoRevisions::validate_memoized_value
  15: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  16: salsa::derived::slot::Slot<Q,MP>::read
  17: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  18: <DB as hir_ty::db::HirDatabase>::impl_datum
  19: chalk_solve::clauses::program_clauses_that_could_match
  20: chalk_recursive::solve::SolveIteration::solve_iteration
  21: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  22: chalk_recursive::fulfill::Fulfill<I,Solver>::prove
  23: chalk_recursive::fulfill::Fulfill<I,Solver>::solve
  24: chalk_recursive::solve::SolveIteration::solve_iteration
  25: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  26: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_root_goal
  27: <hir_ty::db::TraitSolveQueryQuery as salsa::plumbing::QueryFunction>::execute
  28: salsa::runtime::Runtime::execute_query_implementation
  29: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  30: salsa::derived::slot::Slot<Q,MP>::read
  31: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  32: <DB as hir_ty::db::HirDatabase>::trait_solve_query::__shim
  33: <DB as hir_ty::db::HirDatabase>::trait_solve_query
  34: hir_ty::db::trait_solve_wait
  35: <DB as hir_ty::db::HirDatabase>::trait_solve
  36: hir_ty::infer::unify::InferenceTable::register_obligation_in_env
  37: hir_ty::infer::unify::InferenceTable::normalize_projection_ty
  38: <hir_ty::fold_tys::TyFolder<F> as chalk_ir::fold::Folder<hir_ty::interner::Interner>>::fold_ty
  39: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::GenericArg<I>>::fold_with
  40: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  41: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Substitution<I>>::fold_with
  42: <chalk_ir::Ty<I> as chalk_ir::fold::SuperFold<I>>::super_fold_with
  43: <hir_ty::fold_tys::TyFolder<F> as chalk_ir::fold::Folder<hir_ty::interner::Interner>>::fold_ty
  44: hir_ty::infer::InferenceContext::make_ty_with_mode
  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::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  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_db::defs::NameRefClass::classify
  55: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  56: <itertools::unique_impl::Unique<I> as core::iter::traits::iterator::Iterator>::next
  57: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  58: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  59: ide::goto_implementation::goto_implementation
  60: std::panicking::try
  61: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  62: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  63: rust_analyzer::handlers::handle_hover
  64: std::panicking::try
  65: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 18:02:53] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 5
  Code: -32603 
Panic context:
> 
version: 5506e0dfa 2021-09-04 nightly
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: 620,
            character: 56,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> DefMap CrateId(781) 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:394: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::nameres::path_resolution::<impl hir_def::nameres::DefMap>::resolve_path_fp_with_macro
   5: hir_def::macro_call_as_call_id
   6: <hir_expand::InFile<&syntax::ast::generated::nodes::MacroCall> as hir_def::AsMacroCall>::as_call_id_with_errors
   7: hir_def::body::Expander::enter_expand
   8: hir_def::data::collect_items
   9: hir_def::data::TraitData::trait_data_query
  10: salsa::runtime::Runtime::execute_query_implementation
  11: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  12: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  13: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  14: salsa::derived::slot::MemoRevisions::validate_memoized_value
  15: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  16: salsa::derived::slot::Slot<Q,MP>::read
  17: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  18: <DB as hir_ty::db::HirDatabase>::impl_datum
  19: chalk_solve::clauses::program_clauses_that_could_match
  20: chalk_recursive::solve::SolveIteration::solve_iteration
  21: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  22: chalk_recursive::fulfill::Fulfill<I,Solver>::prove
  23: chalk_recursive::fulfill::Fulfill<I,Solver>::solve
  24: chalk_recursive::solve::SolveIteration::solve_iteration
  25: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  26: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_root_goal
  27: <hir_ty::db::TraitSolveQueryQuery as salsa::plumbing::QueryFunction>::execute
  28: salsa::runtime::Runtime::execute_query_implementation
  29: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  30: salsa::derived::slot::Slot<Q,MP>::read
  31: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  32: <DB as hir_ty::db::HirDatabase>::trait_solve_query::__shim
  33: <DB as hir_ty::db::HirDatabase>::trait_solve_query
  34: hir_ty::db::trait_solve_wait
  35: <DB as hir_ty::db::HirDatabase>::trait_solve
  36: hir_ty::infer::unify::InferenceTable::register_obligation_in_env
  37: hir_ty::infer::unify::InferenceTable::normalize_projection_ty
  38: <hir_ty::fold_tys::TyFolder<F> as chalk_ir::fold::Folder<hir_ty::interner::Interner>>::fold_ty
  39: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::GenericArg<I>>::fold_with
  40: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  41: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Substitution<I>>::fold_with
  42: <chalk_ir::Ty<I> as chalk_ir::fold::SuperFold<I>>::super_fold_with
  43: <hir_ty::fold_tys::TyFolder<F> as chalk_ir::fold::Folder<hir_ty::interner::Interner>>::fold_ty
  44: hir_ty::infer::InferenceContext::make_ty_with_mode
  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::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  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_db::defs::NameRefClass::classify
  55: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  56: <itertools::unique_impl::Unique<I> as core::iter::traits::iterator::Iterator>::next
  57: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  58: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  59: ide::goto_implementation::goto_implementation
  60: std::panicking::try
  61: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  62: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  63: rust_analyzer::handlers::handle_hover
  64: std::panicking::try
  65: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: 5506e0dfa 2021-09-04 nightly
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/test_utils.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 598,
            character: 37,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> DefMap CrateId(1069) None path Registry

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:394: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_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: <DB as hir_ty::db::HirDatabase>::impl_self_ty
  12: hir_ty::lower::impl_trait_query
  13: salsa::runtime::Runtime::execute_query_implementation
  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>::trait_impls_in_crate
  22: hir::Impl::all_for_type
  23: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  24: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  25: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  26: ide::goto_implementation::goto_implementation
  27: std::panicking::try
  28: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  29: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  30: rust_analyzer::handlers::handle_hover
  31: std::panicking::try
  32: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 18:03:29] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 1
  Code: -32603 
Panic context:
> 
version: 5506e0dfa 2021-09-04 nightly
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/test_utils.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 731,
            character: 36,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> DefMap CrateId(1069) None path Registry

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:394: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_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: <DB as hir_ty::db::HirDatabase>::impl_self_ty
  12: hir_ty::lower::impl_trait_query
  13: salsa::runtime::Runtime::execute_query_implementation
  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>::trait_impls_in_crate
  22: hir::Impl::all_for_type
  23: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  24: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  25: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  26: ide::goto_implementation::goto_implementation
  27: std::panicking::try
  28: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  29: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  30: rust_analyzer::handlers::handle_hover
  31: std::panicking::try
  32: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: 5506e0dfa 2021-09-04 nightly
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/benches/state_res_bench.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 690,
            character: 46,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> DefMap CrateId(1069) None path Registry

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:394: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_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: <DB as hir_ty::db::HirDatabase>::impl_self_ty
  12: hir_ty::lower::impl_trait_query
  13: salsa::runtime::Runtime::execute_query_implementation
  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>::trait_impls_in_crate
  22: hir::Impl::all_for_type
  23: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  24: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  25: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  26: ide::goto_implementation::goto_implementation
  27: std::panicking::try
  28: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  29: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  30: rust_analyzer::handlers::handle_hover
  31: std::panicking::try
  32: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 18:08:01] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 1
  Code: -32603 
Panic context:
> 
version: 5506e0dfa 2021-09-04 nightly
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/state_event.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 33,
            character: 45,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> DefMap CrateId(1069) None path Registry

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:394: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_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: <DB as hir_ty::db::HirDatabase>::impl_self_ty
  12: hir_ty::lower::impl_trait_query
  13: salsa::runtime::Runtime::execute_query_implementation
  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>::trait_impls_in_crate
  22: hir::Impl::all_for_trait
  23: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  24: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  25: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  26: ide::goto_implementation::goto_implementation
  27: std::panicking::try
  28: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  29: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  30: rust_analyzer::handlers::handle_hover
  31: std::panicking::try
  32: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 18:13:43] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 1
  Code: -32603 

bors bot added a commit that referenced this issue Sep 5, 2021
10159: Add panic info for `impl_trait`/`trait_data` r=jonas-schievink a=jonas-schievink

To debug #10084 further

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
@jonas-schievink
Copy link
Contributor

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

@jplatte
Copy link
Contributor

jplatte commented Sep 8, 2021

Panic context:
> 
version: 3dae94bf2 2021-09-08 nightly
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/matrix-rust-sdk/matrix_sdk/tests/event_handler.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 3,
            character: 37,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> impl_trait_query(ImplId(22411) -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Drop"))] }, generic_args: [None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("MemBioSlice"))] }, generic_args: [Some(GenericArgs { args: [Lifetime(LifetimeRef { name: Name(Text("'a")) })], has_self_type: false, bindings: [] })] }), items: [FunctionId(FunctionId(33621))], is_negative: false })

> DefMap CrateId(756) crate_name=Some(CrateDisplayName { crate_name: CrateName("mod"), canonical_name: "mod" }) block=None path=MemBioSlice

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 2', crates/hir_def/src/nameres/path_resolution.rs:395: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_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: <DB as hir_ty::db::HirDatabase>::impl_self_ty
  12: hir_ty::lower::impl_trait_query
  13: salsa::runtime::Runtime::execute_query_implementation
  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>::trait_impls_in_crate
  22: hir::Impl::all_for_type
  23: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  24: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  25: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  26: ide::goto_implementation::goto_implementation
  27: std::panicking::try
  28: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  29: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  30: rust_analyzer::handlers::handle_hover
  31: std::panicking::try
  32: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 23:03:05] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 2
  Code: -32603 
Panic context:
> 
version: 3dae94bf2 2021-09-08 nightly
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/matrix-rust-sdk/matrix_sdk/src/client.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 3251,
            character: 36,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> impl_trait_query(ImplId(77846) -> ImplData { target_trait: None, self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Deserializer"))] }, generic_args: [Some(GenericArgs { args: [Lifetime(LifetimeRef { name: Name(Text("'a")) })], has_self_type: false, bindings: [] })] }), items: [FunctionId(FunctionId(154600)), FunctionId(FunctionId(154601)), FunctionId(FunctionId(154602)), FunctionId(FunctionId(154603))], is_negative: false })

> DefMap CrateId(1131) crate_name=Some(CrateDisplayName { crate_name: CrateName("test_de"), canonical_name: "test_de" }) block=None path=Deserializer

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 2', crates/hir_def/src/nameres/path_resolution.rs:395: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_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: <DB as hir_ty::db::HirDatabase>::impl_self_ty
  12: hir_ty::lower::impl_trait_query
  13: salsa::runtime::Runtime::execute_query_implementation
  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>::trait_impls_in_crate
  22: hir::Impl::all_for_type
  23: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  24: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  25: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  26: ide::goto_implementation::goto_implementation
  27: std::panicking::try
  28: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  29: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  30: rust_analyzer::handlers::handle_hover
  31: std::panicking::try
  32: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 23:15:39] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 2
  Code: -32603 

bors bot added a commit that referenced this issue Sep 9, 2021
10185: minor: include `ImplLoc` in panic context r=jonas-schievink a=jonas-schievink

cc #10084

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
@jonas-schievink
Copy link
Contributor

jonas-schievink commented Sep 9, 2021

Looking at the last one in more detail:

> impl_trait_query(ImplId(77846) -> ImplData { target_trait: None, self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Deserializer"))] }, generic_args: [Some(GenericArgs { args: [Lifetime(LifetimeRef { name: Name(Text("'a")) })], has_self_type: false, bindings: [] })] }), items: [FunctionId(FunctionId(154600)), FunctionId(FunctionId(154601)), FunctionId(FunctionId(154602)), FunctionId(FunctionId(154603))], is_negative: false })

> DefMap CrateId(1131) crate_name=Some(CrateDisplayName { crate_name: CrateName("test_de"), canonical_name: "test_de" }) block=None path=Deserializer

We're trying to get the trait implemented by this serde-yaml impl (which is None, of course). We query the impl's self type, Deserializer<'a>, and resolve that.

Now for some reason, it is using the DefMap of the test_de test in serde-yaml (which only has 1 module) to resolve Deserializer, but from a module that isn't part of this DefMap.

This still makes no sense at all to me, so I added some more info to the context in #10185. @jplatte do you by any chance remember what triggered these panics? I'm still not having any luck reproducing this locally.

@jplatte
Copy link
Contributor

jplatte commented Sep 9, 2021

I was working on matrix-org/matrix-rust-sdk#309. Maybe you can fudge around with the code introduced by the second-to-last commit there? I think when writing that I got this (but also earlier when working on the same PR).

Either way I'm probably going to work on a followup PR to that in the next days so chances seem high that I'll trigger the bug again 😄

@jplatte
Copy link
Contributor

jplatte commented Sep 11, 2021

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

@Veykril
Copy link
Member

Veykril commented Sep 12, 2021

Panicking whenever hovering the Option here in my current session https://github.com/rust-analyzer/rust-analyzer/blob/516eb40ba5b9d20e59e98185d1b2fcba5599ef7a/crates/base_db/src/fixture.rs#L91

Interestingly enough, the output of the debug prints you added differs on each panic... and if triggered often enough it stops panicking.

> 
version: 3e056b9e90 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: "/c%3A/Workspace/Rust/rust-analyzer/crates/base_db/src/fixture.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 90,
            character: 42,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> impl_trait_query(ImplId(20425) -> ItemLoc { container: ModuleId { krate: CrateId(330), block: None, local_id: Idx::<ModuleData>(1) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(1788))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: None, self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("HtmlWriter"))] }, generic_args: [Some(GenericArgs { args: [Lifetime(LifetimeRef { name: Name(Text("'a")) }), Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("I"))] }, generic_args: [None] })), Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("W"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), items: [FunctionId(FunctionId(58914)), FunctionId(FunctionId(58915)), FunctionId(FunctionId(58916)), FunctionId(FunctionId(58917)), FunctionId(FunctionId(58918)), FunctionId(FunctionId(58919)), FunctionId(FunctionId(58920))], is_negative: false })

> impl_self_ty_query(ImplId(20425) -> ItemLoc { container: ModuleId { krate: CrateId(330), block: None, local_id: Idx::<ModuleData>(1) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(1788))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: None, self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("HtmlWriter"))] }, generic_args: [Some(GenericArgs { args: [Lifetime(LifetimeRef { name: Name(Text("'a")) }), Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("I"))] }, generic_args: [None] })), Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("W"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), items: [FunctionId(FunctionId(58914)), FunctionId(FunctionId(58915)), FunctionId(FunctionId(58916)), FunctionId(FunctionId(58917)), FunctionId(FunctionId(58918)), FunctionId(FunctionId(58919)), FunctionId(FunctionId(58920))], is_negative: false })

> DefMap CrateId(330) crate_name=Some(CrateDisplayName { crate_name: CrateName("pulldown_cmark"), canonical_name: "pulldown-cmark" }) block=None path=HtmlWriter

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:395:33
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b\/library\std\src\panicking.rs:515
   1: core::panicking::panic_fmt
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b\/library\core\src\panicking.rs:92
   2: core::panicking::panic_bounds_check
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b\/library\core\src\panicking.rs:69
   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_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: core::ptr::drop_in_place<core::option::Option<chalk_ir::Variances<hir_ty::interner::Interner>>>
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: <DB as hir_ty::db::HirDatabase>::impl_self_ty::__shim
  12: hir_ty::lower::impl_trait_query
  13: salsa::runtime::Runtime::execute_query_implementation
  14: core::ptr::drop_in_place<core::option::Option<chalk_ir::Variances<hir_ty::interner::Interner>>>
  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: hir_ty::db::HirDatabaseGroupStorage__::maybe_changed_since
  18: <ide_db::RootDatabase as salsa::plumbing::DatabaseOps>::maybe_changed_since
  19: salsa::derived::slot::MemoRevisions::validate_memoized_value
  20: core::ptr::drop_in_place<core::option::Option<chalk_ir::Variances<hir_ty::interner::Interner>>>
  21: salsa::derived::slot::Slot<Q,MP>::read
  22: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  23: <DB as hir_ty::db::HirDatabase>::trait_impls_in_crate::__shim
  24: hir::Impl::all_for_type
  25: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  26: hashbrown::raw::RawTable<T,A>::shrink_to
  27: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  28: ide::goto_implementation::goto_implementation
  29: std::panicking::try
  30: ide::Analysis::goto_implementation
  31: rust_analyzer::handlers::show_impl_command_link
  32: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  33: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  34: rust_analyzer::handlers::handle_hover
  35: std::panicking::try
  36: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 오전 12:57:31] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 1
  Code: -32603 

I re-hovered the ident until it stopped panicking at which point it worked normally, here is the entire panic log for this https://gist.github.com/Veykril/9c189877bb965b006bdd0eefa5570ec5

Edit: Just ran into this again, this time hovering std's Arc, at which point hovering any type or trait of std caused the panic.

@yuyoyuppe
Copy link

yuyoyuppe commented Sep 14, 2021

Same issue for me as for @Veykril. Can provide more info if needed.

@f32by
Copy link

f32by commented Sep 15, 2021

Same issue for me.

Log: https://gist.github.com/f32by/4ed1151cdb5a71e39fc0d46970fb540a

Panicking when hovering AsRef and Display in following code snippet.

impl<T> ExpectLogError<T> for Option<T> {
    #[inline]
    fn expect_log_err<S>(self, msg: S) -> T
    where
        S: AsRef<str> + fmt::Display,
    {
        match self {
            Some(v) => v,
            None => panic_with_log!(msg),
        }
    }
}

@Veykril
Copy link
Member

Veykril commented Sep 15, 2021

After adding some asserts for myself and having fortunately triggered some of them it seems like the tuple in the vec![(def_map.clone(), self.local_id)]; here
https://github.com/rust-analyzer/rust-analyzer/blob/c577e128fc3aa9d5cf113c24c7f425e2b68bb2b6/crates/hir_def/src/resolver.rs#L739-L753
is incorrect.
Unfortunately forgot to save the stracktrace but the previous call was <hir_def::ImplId as hir_def::resolver::HasResolver>::resolver and then its basically the same stacktrace as the other ones.

So we are somehow creating an invalid module_id in an ImplLoc somewhere which doesn't really make sense... or the def_map query is incorrect.

@jonas-schievink
Copy link
Contributor

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.

@jplatte
Copy link
Contributor

jplatte commented Sep 21, 2021

Not sure whether more backtraces are useful, but here is another one and I actually had a closer look. The type being referenced (that's supposed to be resolved?), UnsupportedError, is one that I have no idea where it could come from because that string is not found within the entire codebase I'm working on. Full error:

Panic context:
> 
version: f1d7f98ed 2021-09-20 nightly
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/matrix-rust-sdk/crates/matrix-sdk/src/event_handler.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 110,
            character: 68,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> impl_trait_query(ImplId(22546) -> ItemLoc { container: ModuleId { krate: CrateId(567), block: None, local_id: Idx::<ModuleData>(1) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(2965))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: None, self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("UnsupportedError"))] }, generic_args: [None] }), items: [FunctionId(FunctionId(31274)), FunctionId(FunctionId(31275)), FunctionId(FunctionId(31276))], is_negative: false })

> impl_self_ty_query(ImplId(22546) -> ItemLoc { container: ModuleId { krate: CrateId(567), block: None, local_id: Idx::<ModuleData>(1) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(2965))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: None, self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("UnsupportedError"))] }, generic_args: [None] }), items: [FunctionId(FunctionId(31274)), FunctionId(FunctionId(31275)), FunctionId(FunctionId(31276))], is_negative: false })

> DefMap CrateId(567) crate_name=Some(CrateDisplayName { crate_name: CrateName("all"), canonical_name: "all" }) block=None path=UnsupportedError

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:395:33
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:92:14
   2: core::panicking::panic_bounds_check
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/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_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: <DB as hir_ty::db::HirDatabase>::impl_self_ty
  12: hir_ty::lower::impl_trait_query
  13: salsa::runtime::Runtime::execute_query_implementation
  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>::trait_impls_in_crate
  22: hir::Impl::all_for_type
  23: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  24: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  25: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  26: ide::goto_implementation::goto_implementation
  27: std::panicking::try
  28: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  29: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  30: rust_analyzer::handlers::handle_hover
  31: std::panicking::try
  32: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 12:30:46] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 1
  Code: -32603 

@lnicola
Copy link
Member

lnicola commented Sep 21, 2021

@jplatte that might come from the image crate, but I wonder why it says all.

@nkrackow
Copy link

Hi, seems like a very annoying and persistent problem.. Thanks for investigating.

[Error - 9:36:27 AM] Request textDocument/definition failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 2
  Code: -32603 

AFAICT there is currently no workaround, right?

@jplatte
Copy link
Contributor

jplatte commented Aug 11, 2022

Just happened again to me after a long time of no such error (I think). Not on hover but on git stash in the terminal, when rust-analyzer was reacting to a bunch of files changing at once. Log, including a possibly separate issue at the start

[Error - 10:17:43] Request textDocument/semanticTokens/range failed.
  Message: Invalid offset
  Code: -32603 
Panic context:
> 
version: 0.3.1162-standalone (634cfe3d7 2022-08-07)
request: textDocument/codeAction CodeActionParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/jplatte/code/matrix-rust-sdk/testing/matrix-sdk-integration-testing/src/tests.rs",
            query: None,
            fragment: None,
        },
    },
    range: Range {
        start: Position {
            line: 13,
            character: 14,
        },
        end: Position {
            line: 13,
            character: 14,
        },
    },
    context: CodeActionContext {
        diagnostics: [],
        only: None,
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
}

> impl_self_ty_query(ImplId(49368) -> ItemLoc { container: ModuleId { krate: CrateId(409), block: None, local_id: Idx::<ModuleData>(3) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(5898))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: None, self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Alt"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("V"))] }, generic_args: [None] }))], has_self_type: false, bindings: [], desugared_from_fn: false })] }), items: [FunctionId(FunctionId(23241))], is_negative: false, attribute_calls: None })

> DefMap CrateId(409) crate_name=Some(CrateDisplayName { crate_name: CrateName("try_lock"), canonical_name: "try-lock" }) block=None path=Alt

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:381:33
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: core::panicking::panic_bounds_check
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:84: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_ty_ext
   6: hir_ty::lower::impl_self_ty_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>::inherent_impls_in_crate::__shim
  16: <hir_ty::db::InherentImplCratesQuery as salsa::plumbing::QueryFunction>::execute
  17: salsa::runtime::Runtime::execute_query_implementation
  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: salsa::QueryTable<Q>::get
  22: <DB as hir_ty::db::HirDatabase>::inherent_impl_crates
  23: hir_ty::method_resolution::def_crates
  24: hir_ty::method_resolution::iterate_inherent_methods
  25: hir_ty::method_resolution::iterate_method_candidates_by_receiver
  26: hir_ty::method_resolution::iterate_method_candidates_dyn
  27: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  28: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  29: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  30: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  31: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  32: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  33: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  34: hir_ty::infer::infer_query
  35: salsa::runtime::Runtime::execute_query_implementation
  36: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  37: salsa::derived::slot::Slot<Q,MP>::read
  38: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  39: salsa::QueryTable<Q>::get
  40: <DB as hir_ty::db::HirDatabase>::infer_query
  41: hir_ty::db::infer_wait
  42: hir::DefWithBody::diagnostics
  43: hir::ModuleDef::diagnostics
  44: hir::Module::diagnostics
  45: ide_diagnostics::diagnostics
  46: std::panicking::try
  47: ide::Analysis::assists_with_fixes
  48: rust_analyzer::handlers::handle_code_action
  49: std::panicking::try
  50: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[ERROR rust_analyzer::lsp_utils] failed to run build scripts

error[E0554]: `#![feature]` may not be used on the beta release channel
   --> /home/jplatte/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.61/src/lib.rs:214:32
    |
214 | #![cfg_attr(backtrace, feature(backtrace))]
    |                                ^^^^^^^^^


error: aborting due to previous error


For more information about this error, try `rustc --explain E0554`.

error: could not compile `anyhow` due to 2 previous errors


[ERROR rust_analyzer::lsp_utils] failed to run build scripts

error[E0554]: `#![feature]` may not be used on the beta release channel
   --> /home/jplatte/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.61/src/lib.rs:214:32
    |
214 | #![cfg_attr(backtrace, feature(backtrace))]
    |                                ^^^^^^^^^


error: aborting due to previous error


For more information about this error, try `rustc --explain E0554`.

error: could not compile `anyhow` due to 2 previous errors


[ERROR rust_analyzer::lsp_utils] failed to run build scripts

error[E0554]: `#![feature]` may not be used on the beta release channel
   --> /home/jplatte/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.61/src/lib.rs:214:32
    |
214 | #![cfg_attr(backtrace, feature(backtrace))]
    |                                ^^^^^^^^^


error: aborting due to previous error


For more information about this error, try `rustc --explain E0554`.

error: could not compile `anyhow` due to 2 previous errors


[ERROR rust_analyzer::lsp_utils] failed to run build scripts

error[E0554]: `#![feature]` may not be used on the beta release channel
   --> /home/jplatte/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.61/src/lib.rs:214:32
    |
214 | #![cfg_attr(backtrace, feature(backtrace))]
    |                                ^^^^^^^^^


error: aborting due to previous error


For more information about this error, try `rustc --explain E0554`.

error: could not compile `anyhow` due to 2 previous errors


[ERROR rust_analyzer::lsp_utils] failed to run build scripts

error[E0554]: `#![feature]` may not be used on the beta release channel
   --> /home/jplatte/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.61/src/lib.rs:214:32
    |
214 | #![cfg_attr(backtrace, feature(backtrace))]
    |                                ^^^^^^^^^


error: aborting due to previous error


For more information about this error, try `rustc --explain E0554`.

error: could not compile `anyhow` due to 2 previous errors


[ERROR rust_analyzer::lsp_utils] failed to run build scripts

error[E0554]: `#![feature]` may not be used on the beta release channel
   --> /home/jplatte/.cargo/registry/src/github.com-1ecc6299db9ec823/anyhow-1.0.61/src/lib.rs:214:32
    |
214 | #![cfg_attr(backtrace, feature(backtrace))]
    |                                ^^^^^^^^^


error: aborting due to previous error


For more information about this error, try `rustc --explain E0554`.

error: could not compile `anyhow` due to 2 previous errors


Panic context:
> 
version: 0.3.1162-standalone (634cfe3d7 2022-08-07)
request: textDocument/semanticTokens/full/delta SemanticTokensDeltaParams {
    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/jplatte/code/matrix-rust-sdk/labs/sled-state-inspector/src/main.rs",
            query: None,
            fragment: None,
        },
    },
    previous_result_id: "101",
}

> impl_trait_query(ImplId(97447) -> ItemLoc { container: ModuleId { krate: CrateId(396), block: None, local_id: Idx::<ModuleData>(7) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(5569))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Sync"))] }, generic_args: [None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("ScopedKey"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [], desugared_from_fn: false })] }), items: [], is_negative: false, attribute_calls: None })

> impl_self_ty_query(ImplId(97447) -> ItemLoc { container: ModuleId { krate: CrateId(396), block: None, local_id: Idx::<ModuleData>(7) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(5569))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Sync"))] }, generic_args: [None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("ScopedKey"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [], desugared_from_fn: false })] }), items: [], is_negative: false, attribute_calls: None })

> DefMap CrateId(396) crate_name=Some(CrateDisplayName { crate_name: CrateName("tinyvec_macros"), canonical_name: "tinyvec_macros" }) block=None path=ScopedKey

thread 'Worker' panicked at 'index out of bounds: the len is 1 but the index is 7', crates/hir-def/src/nameres/path_resolution.rs:381:33
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: core::panicking::panic_bounds_check
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:84: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_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: salsa::QueryTable<Q>::get
  12: <DB as hir_ty::db::HirDatabase>::impl_self_ty
  13: hir_ty::lower::impl_trait_query
  14: salsa::runtime::Runtime::execute_query_implementation
  15: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  16: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  17: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  18: salsa::derived::slot::MemoRevisions::validate_memoized_value
  19: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  20: salsa::derived::slot::Slot<Q,MP>::read
  21: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  22: <DB as hir_ty::db::HirDatabase>::trait_impls_in_crate::__shim
  23: <hir_ty::db::TraitImplsInDepsQuery as salsa::plumbing::QueryFunction>::execute
  24: salsa::runtime::Runtime::execute_query_implementation
  25: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  26: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  27: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  28: salsa::derived::slot::MemoRevisions::validate_memoized_value
  29: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  30: salsa::derived::slot::Slot<Q,MP>::read
  31: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  32: salsa::QueryTable<Q>::get
  33: <DB as hir_ty::db::HirDatabase>::trait_solve_query
  34: hir_ty::db::trait_solve_wait
  35: <DB as hir_ty::db::HirDatabase>::trait_solve
  36: hir_ty::infer::coerce::<impl hir_ty::infer::unify::InferenceTable>::coerce_inner
  37: hir_ty::infer::coerce::<impl hir_ty::infer::unify::InferenceTable>::coerce
  38: hir_ty::infer::coerce::<impl hir_ty::infer::InferenceContext>::coerce
  39: hir_ty::infer::coerce::CoerceMany::coerce
  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_inner
  42: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  43: hir_ty::infer::infer_query
  44: salsa::runtime::Runtime::execute_query_implementation
  45: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  46: salsa::derived::slot::Slot<Q,MP>::read
  47: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  48: salsa::QueryTable<Q>::get
  49: <DB as hir_ty::db::HirDatabase>::infer_query
  50: hir_ty::db::infer_wait
  51: hir::source_analyzer::SourceAnalyzer::new_for_body
  52: hir::semantics::SemanticsImpl::analyze_impl
  53: ide_db::defs::NameRefClass::classify
  54: ide::syntax_highlighting::highlight::name_like
  55: ide::syntax_highlighting::highlight
  56: std::panicking::try
  57: rust_analyzer::handlers::handle_semantic_tokens_full_delta
  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: 0.3.1162-standalone (634cfe3d7 2022-08-07)
request: textDocument/semanticTokens/full/delta SemanticTokensDeltaParams {
    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/jplatte/code/matrix-rust-sdk/testing/matrix-sdk-integration-testing/src/tests.rs",
            query: None,
            fragment: None,
        },
    },
    previous_result_id: "100",
}

> impl_trait_query(ImplId(121825) -> ItemLoc { container: ModuleId { krate: CrateId(441), block: None, local_id: Idx::<ModuleData>(1) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(6241))), block: None }, value: Idx::<Impl>(1) } } -> ImplData { target_trait: None, self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Context"))] }, generic_args: [None] }), items: [FunctionId(FunctionId(137427)), FunctionId(FunctionId(137428)), FunctionId(FunctionId(137429))], is_negative: false, attribute_calls: None })

> impl_self_ty_query(ImplId(121825) -> ItemLoc { container: ModuleId { krate: CrateId(441), block: None, local_id: Idx::<ModuleData>(1) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(6241))), block: None }, value: Idx::<Impl>(1) } } -> ImplData { target_trait: None, self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Context"))] }, generic_args: [None] }), items: [FunctionId(FunctionId(137427)), FunctionId(FunctionId(137428)), FunctionId(FunctionId(137429))], is_negative: false, attribute_calls: None })

> DefMap CrateId(441) crate_name=Some(CrateDisplayName { crate_name: CrateName("wasm_bindgen_shared"), canonical_name: "wasm-bindgen-shared" }) block=None path=Context

thread 'Worker' panicked at 'index out of bounds: the len is 1 but the index is 1', crates/hir-def/src/nameres/path_resolution.rs:381:33
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: core::panicking::panic_bounds_check
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:84: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_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: salsa::QueryTable<Q>::get
  12: <DB as hir_ty::db::HirDatabase>::impl_self_ty
  13: hir_ty::lower::impl_trait_query
  14: salsa::runtime::Runtime::execute_query_implementation
  15: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  16: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  17: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  18: salsa::derived::slot::MemoRevisions::validate_memoized_value
  19: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  20: salsa::derived::slot::Slot<Q,MP>::read
  21: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  22: <DB as hir_ty::db::HirDatabase>::trait_impls_in_crate::__shim
  23: <hir_ty::db::TraitImplsInDepsQuery as salsa::plumbing::QueryFunction>::execute
  24: salsa::runtime::Runtime::execute_query_implementation
  25: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  26: salsa::derived::slot::Slot<Q,MP>::read
  27: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  28: <DB as hir_ty::db::HirDatabase>::trait_impls_in_deps::__shim
  29: hir_ty::chalk_db::<impl chalk_solve::RustIrDatabase<hir_ty::interner::Interner> for hir_ty::traits::ChalkContext>::impls_for_trait
  30: chalk_recursive::solve::SolveIteration::solve_iteration
  31: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  32: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_root_goal
  33: <hir_ty::db::TraitSolveQueryQuery as salsa::plumbing::QueryFunction>::execute
  34: salsa::runtime::Runtime::execute_query_implementation
  35: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  36: salsa::derived::slot::Slot<Q,MP>::read
  37: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  38: salsa::QueryTable<Q>::get
  39: <DB as hir_ty::db::HirDatabase>::trait_solve_query
  40: hir_ty::db::trait_solve_wait
  41: <DB as hir_ty::db::HirDatabase>::trait_solve
  42: hir_ty::infer::coerce::<impl hir_ty::infer::unify::InferenceTable>::coerce_inner
  43: hir_ty::infer::coerce::<impl hir_ty::infer::unify::InferenceTable>::coerce
  44: hir_ty::infer::coerce::<impl hir_ty::infer::InferenceContext>::coerce
  45: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  46: hir_ty::infer::infer_query
  47: salsa::runtime::Runtime::execute_query_implementation
  48: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  49: salsa::derived::slot::Slot<Q,MP>::read
  50: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  51: salsa::QueryTable<Q>::get
  52: <DB as hir_ty::db::HirDatabase>::infer_query
  53: hir_ty::db::infer_wait
  54: hir::source_analyzer::SourceAnalyzer::new_for_body
  55: hir::semantics::SemanticsImpl::analyze_impl
  56: ide_db::defs::NameRefClass::classify
  57: ide::syntax_highlighting::highlight::name_like
  58: ide::syntax_highlighting::highlight
  59: std::panicking::try
  60: rust_analyzer::handlers::handle_semantic_tokens_full_delta
  61: std::panicking::try
  62: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@lnicola
Copy link
Member

lnicola commented Aug 11, 2022

@jplatte Did you maybe just add a new dependency or change its version during git stash?

The other error is a known issue. I suggest upgrading to anyhow 1.0.61, doing a cargo clean, and possibly disabling rust-analyzer.cargo.buildScripts.useRustcWrapper. CC #12973.

@jplatte
Copy link
Contributor

jplatte commented Aug 11, 2022

Yes, that git stash replaced once_cell with lazy_static I think. I know the anyhow issue is separate. I am already on 1.0.61, thanks for letting me know about the workaround :)

@grishy
Copy link

grishy commented Feb 22, 2023

Also crushed.

Error
Panic context:
> 
version: 0.3.1410-standalone (a6603fc21 2023-02-16)
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: 15,
            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(
                ".",
            ),
        },
    ),
}

> impl_self_ty_query(ImplId(24954) -> ItemLoc { container: ModuleId { krate: CrateId(41), block: None, local_id: Idx::<ModuleData>(5) }, id: ItemTreeId { tree: TreeId { file: HirFileId(2100), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: None, self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Data"))] }, generic_args: None }), items: [FunctionId(FunctionId(50183)), FunctionId(FunctionId(50184))], is_negative: false, attribute_calls: None })

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

thread 'Worker' panicked at 'index out of bounds: the len is 1 but the index is 5', 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::resolver::Resolver::resolve_path_in_type_ns
   5: hir_ty::lower::TyLoweringContext::lower_ty_ext
   6: hir_ty::lower::impl_self_ty_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>::inherent_impls_in_crate::__shim
  16: hir_ty::method_resolution::incoherent_inherent_impl_crates
  17: salsa::runtime::Runtime::execute_query_implementation
  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>::incoherent_inherent_impl_crates::__shim
  22: <DB as hir_ty::db::HirDatabase>::incoherent_inherent_impl_crates
  23: hir_ty::method_resolution::def_crates
  24: hir_ty::method_resolution::iterate_inherent_methods
  25: hir_ty::method_resolution::iterate_method_candidates_by_receiver
  26: hir_ty::method_resolution::iterate_method_candidates_dyn
  27: hir::Type::iterate_method_candidates_dyn
  28: hir::Type::iterate_method_candidates
  29: ide_db::imports::import_assets::trait_applicable_items
  30: ide_db::imports::import_assets::ImportAssets::search_for
  31: ide_db::imports::import_assets::ImportAssets::search_for_imports
  32: ide_completion::completions::flyimport::import_on_the_fly_dot
  33: ide_completion::completions::complete_name_ref
  34: ide_completion::completions
  35: std::panicking::try
  36: rust_analyzer::handlers::handle_completion
  37: std::panicking::try
  38: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 23:44:35] Request textDocument/completion failed.
  Message: request handler panicked: index out of bounds: the len is 1 but the index is 5
  Code: -32603 

On that part of code:

# main.rs
use macroquad::prelude::*;
use tiled::Loader;

#[macroquad::main("Qunshine")]
async fn main() {
    // Load json file exported from tiled
    let mut loader = Loader::new();
    let map = loader.load_tmx_map("...").unwrap();
    let tileset = loader.load_tsx_tileset("...").unwrap();

    println!("{:?}", map.get_layer(0));
    let l = map.get_layer(0).unwrap();
    let m = l.map();
    let t = m.tilesets();
    t. # <-Here 

When you type dot (.) after t.

@grishy
Copy link

grishy commented Feb 25, 2023

@jonas-schievink I saw that you were dealing with this problem, it seems that the problem still exists ;(
Or are recent messages another problem?
Thanks

@lnicola
Copy link
Member

lnicola commented Feb 25, 2023

@grishy I can't reproduce the crash, which rust-analyzer version are you running?

image

If it crashed after you switched git branches, it's the same problem as here, but we don't have a workaround for it.

@grishy
Copy link

grishy commented Feb 25, 2023

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

@lnicola
Copy link
Member

lnicola commented Feb 25, 2023

Yeah, sorry, I missed the version in the previous log. Can you reproduce it reliably in your game (original repo)?

@grishy
Copy link

grishy commented Feb 26, 2023

Yes, I can. I'll try to upload this to github or some other way so that the problem reproduces.
upd. Now I can't reproduce the problem :(

@orende

This comment was marked as off-topic.

@Veykril

This comment was marked as off-topic.

@orende

This comment was marked as off-topic.

@Veykril

This comment was marked as off-topic.

@Veykril

This comment was marked as off-topic.

bors added a commit that referenced this issue May 4, 2023
fix: Fix body lowering not using block def maps

Fixes the issue in the comment here #10084 (comment), not the general issue unfortunately.
@gkorland
Copy link

Just got this error:

> impl_self_ty_query(ImplId(26978) -> ItemLoc { container: ModuleId { krate: Idx::<CrateData>(62), block: None, local_id: Idx::<ModuleData>(1) }, id: ItemTreeId { tree: TreeId { file: HirFileId(2147501022), block: None }, value: Idx::<Impl>(6) } } -> ImplData { target_trait: None, self_ty: Path(Normal { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("ChaCha20Rng"))] }, generic_args: None }), items: [FunctionId(FunctionId(35571)), FunctionId(FunctionId(35572)), FunctionId(FunctionId(35573))], is_negative: false, attribute_calls: None })

> DefMap Idx::<CrateData>(62) crate_name=Some(CrateDisplayName { crate_name: CrateName("enum_primitive_derive"), canonical_name: "enum-primitive-derive" }) block=None path=ChaCha20Rng

thread 'Worker' panicked at 'index out of bounds: the len is 1 but the index is 1', crates/hir-def/src/nameres/path_resolution.rs:390:33
stack backtrace:
   0: rust_begin_unwind
             at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:579:5
   1: core::panicking::panic_fmt
             at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/panicking.rs:64:14
   2: core::panicking::panic_bounds_check
             at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/panicking.rs:159:5
   3: hir_def::nameres::path_resolution::<impl hir_def::nameres::DefMap>::resolve_path_fp_with_macro_single
   4: hir_def::resolver::ModuleItemMap::resolve_path_in_type_ns
   5: hir_def::resolver::Resolver::resolve_path_in_type_ns
   6: hir_ty::lower::TyLoweringContext::lower_ty_ext
   7: <hir_ty::db::ImplSelfTyQuery as salsa::plumbing::QueryFunction>::execute
   8: salsa::runtime::Runtime::execute_query_implementation
   9: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  10: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  11: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  12: salsa::derived::slot::MemoRevisions::validate_memoized_value
  13: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  14: salsa::derived::slot::Slot<Q,MP>::read
  15: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  16: <DB as hir_ty::db::HirDatabase>::inherent_impls_in_crate::__shim
  17: hir_ty::method_resolution::incoherent_inherent_impl_crates
  18: salsa::runtime::Runtime::execute_query_implementation
  19: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  20: salsa::derived::slot::Slot<Q,MP>::read
  21: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  22: <DB as hir_ty::db::HirDatabase>::incoherent_inherent_impl_crates::__shim
  23: <DB as hir_ty::db::HirDatabase>::incoherent_inherent_impl_crates
  24: hir_ty::method_resolution::def_crates
  25: hir_ty::method_resolution::iterate_inherent_methods
  26: hir_ty::method_resolution::iterate_method_candidates_with_autoref::{{closure}}
  27: hir_ty::method_resolution::iterate_method_candidates_dyn
  28: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  29: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::check_call_arguments
  30: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  31: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  32: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  33: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  34: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  35: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_return
  36: hir_ty::infer::infer_query
  37: salsa::runtime::Runtime::execute_query_implementation
  38: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  39: salsa::derived::slot::Slot<Q,MP>::read
  40: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  41: <DB as hir_ty::db::HirDatabase>::infer_query::__shim
  42: <DB as hir_ty::db::HirDatabase>::infer_query
  43: hir_ty::db::infer_wait
  44: <DB as hir_ty::db::HirDatabase>::infer
  45: hir::source_analyzer::SourceAnalyzer::new_for_body
  46: hir::semantics::SemanticsImpl::analyze_impl
  47: ide_db::defs::NameRefClass::classify
  48: ide_db::defs::IdentClass::classify_node
  49: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  50: <itertools::unique_impl::Unique<I> as core::iter::traits::iterator::Iterator>::next
  51: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  52: ide::goto_definition::goto_definition
  53: std::panicking::try
  54: rust_analyzer::handlers::request::handle_goto_definition
  55: std::panicking::try
  56: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 4:21:50 PM] Request textDocument/definition failed.
  Message: request handler panicked: index out of bounds: the len is 1 but the index is 1
  Code: -32603 

@lnicola
Copy link
Member

lnicola commented Jul 21, 2023

Closing as a duplicate of #5366.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-nameres name, path and module resolution Broken Window Bugs / technical debt to be addressed immediately I-panic
Projects
None yet
Development

Successfully merging a pull request may close this issue.