rust-analyzer: Popups about language server requests failing
Every few minutes I keep getting popups in VSCode about textDocument/documentHighlight, textDocument/inlayHint etc failing. The log shows the following:
thread 'Worker' panicked at crates/hir-def/src/attr.rs:368:40:
index out of bounds: the len is 4 but the index is 9
stack backtrace:
0: rust_begin_unwind
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:597:5
1: core::panicking::panic_fmt
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:72:14
2: core::panicking::panic_bounds_check
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:180:5
3: hir_def::attr::AttrsWithOwner::attrs_query
4: salsa::runtime::Runtime::execute_query_implementation
5: salsa::derived::slot::Slot<Q,MP>::read_upgrade
6: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
7: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
8: salsa::derived::slot::MemoRevisions::validate_memoized_value
9: salsa::derived::slot::Slot<Q,MP>::read_upgrade
10: salsa::derived::slot::Slot<Q,MP>::read
11: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
12: <DB as hir_def::db::DefDatabase>::import_map::__shim
13: hir_def::find_path::calculate_best_path
14: hir_def::find_path::find_path_for_module
15: hir_def::find_path::calculate_best_path
16: hir_def::find_path::find_path_inner
17: hir_def::find_path::find_path
18: <chalk_ir::Ty<hir_ty::interner::Interner> as hir_ty::display::HirDisplay>::hir_fmt
19: hir_ty::display::HirDisplay::display_source_code
20: ide::inlay_hints::ty_to_text_edit
21: ide::inlay_hints::bind_pat::hints
22: ide::inlay_hints::hints
23: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
24: ide::inlay_hints::inlay_hints
25: salsa::Cancelled::catch
26: rust_analyzer::handlers::request::handle_inlay_hints
27: std::panicking::try
28: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 11:57:44] Request textDocument/inlayHint failed.
Message: request handler panicked: index out of bounds: the len is 4 but the index is 9
Code: -32603
Panic context:
>
version: 0.3.1740-standalone
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/tmgarn/.rustup/toolchains/1.74.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs",
query: None,
fragment: None,
},
},
position: Position(
Position {
line: 36,
character: 10,
},
),
work_done_progress_params: WorkDoneProgressParams {
work_done_token: None,
},
}
thread 'Worker' panicked at crates/hir-def/src/nameres/path_resolution.rs:422:37:
index out of bounds: the len is 2 but the index is 2
stack backtrace:
0: rust_begin_unwind
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:597:5
1: core::panicking::panic_fmt
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:72:14
2: core::panicking::panic_bounds_check
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:180: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::lower::impl_self_ty_query
8: salsa::runtime::Runtime::execute_query_implementation
9: salsa::derived::slot::Slot<Q,MP>::read_upgrade
10: salsa::derived::slot::Slot<Q,MP>::read
11: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
12: salsa::QueryTable<Q>::get
13: <DB as hir_ty::db::HirDatabase>::impl_self_ty
14: hir_ty::lower::impl_trait_query
15: salsa::runtime::Runtime::execute_query_implementation
16: salsa::derived::slot::Slot<Q,MP>::read_upgrade
17: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
18: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
19: salsa::derived::slot::MemoRevisions::validate_memoized_value
20: salsa::derived::slot::Slot<Q,MP>::read_upgrade
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_trait
25: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
26: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
27: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
28: ide::goto_implementation::goto_implementation
29: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
30: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
31: rust_analyzer::handlers::request::handle_hover
32: std::panicking::try
33: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 12:00:38] Request textDocument/hover failed.
Message: request handler panicked: index out of bounds: the len is 2 but the index is 2
Code: -32603
Panic context:
>
version: 0.3.1740-standalone
request: textDocument/documentHighlight DocumentHighlightParams {
text_document_position_params: TextDocumentPositionParams {
text_document: TextDocumentIdentifier {
uri: Url {
scheme: "file",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/home/tmgarn/workspace/acms_application_shell/services/web/backend/src/drillplan/models.rs",
query: None,
fragment: None,
},
},
position: Position {
line: 29,
character: 66,
},
},
work_done_progress_params: WorkDoneProgressParams {
work_done_token: None,
},
partial_result_params: PartialResultParams {
partial_result_token: None,
},
}
thread 'Worker' panicked at /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.11/src/cursor.rs:751:9:
Bad offset: range 0..800 offset 801
stack backtrace:
0: rust_begin_unwind
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:597:5
1: core::panicking::panic_fmt
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:72:14
2: rowan::cursor::SyntaxNode::token_at_offset
3: ide::highlight_related::highlight_related
4: std::panicking::try
5: rust_analyzer::handlers::request::handle_document_highlight
6: std::panicking::try
7: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 13:12:46] Request textDocument/documentHighlight failed.
Message: request handler panicked: Bad offset: range 0..800 offset 801
Code: -32603
I don’t know what exactly I’m doing to make it happen. I think possibly it happens when rebasing things in git in another terminal window sometimes? Sometimes when I’m reading documentation and not doing anything with the code. Sometimes when I’m writing or refactoring code.
It doesn’t seem to me like anything is actually broken in the user experience. Apart from the popups themselves that is.
Unfortunately the code base I’m working on that is causing this is not open source (so I can’t link it), but it is basically a graph QL micro service that makes GRPC requests as it’s backend. It uses axum, tonic, prost, tower, async-graphql and tracing.
rust-analyzer version: 0.3.1740-standalone
rustc version: rustc 1.74.0 (79e9716c9 2023-11-13) (installed with rustup)
OS: Ubuntu 22.04, using KDE Plasma as my desktop environment
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)
I am using the following workspace config (this is a mixed language project, only a small part is Rust currently, most of it is legacy C++ with CMake) as there is no Cargo.toml in the workspace root:
{
"rust-analyzer.linkedProjects": [
"services/web/backend/Cargo.toml"
]
}
In the user level VSCode settings I have:
"rust-analyzer.diagnostics.warningsAsInfo": [
"dead_code"
],
"rust-analyzer.assist.emitMustUse": true,
(the former makes a lot of sense since I tend to write code bottom up and it gets annoying otherwise)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 15 (7 by maintainers)
The same error happens when working on the open-source
denocodebase. I often have both https://github.com/denoland/deno and https://github.com/denoland/deno_core checked out, and the language server will often crash with this error.There is a known regression wrt to
include!https://github.com/rust-lang/rust-analyzer/issues/16109 which is caused by the tokenmap rewrite, but i haven’t looked into it yet.