Description
rust-analyzer has begun crash-looping in vscode for me:
thread 'main' panicked at 'index out of bounds: the len is 122 but the index is 123', crates/project_model/src/workspace.rs:762:78
stack backtrace:
0: rust_begin_unwind
at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:143:14
2: core::panicking::panic_bounds_check
at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:85:5
3: project_model::workspace::ProjectWorkspace::to_crate_graph
4: rust_analyzer::reload::<impl rust_analyzer::global_state::GlobalState>::switch_workspaces
5: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::handle_event
6: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::run
7: rust_analyzer::main_loop::main_loop
8: rust_analyzer::run_server
9: rust_analyzer::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', /home/runner/.cargo/registry/src/github.spider-man.dpdns.org-1ecc6299db9ec823/lsp-server-0.6.0/src/stdio.rs:29:37
stack backtrace:
0: rust_begin_unwind
at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:143:14
2: core::result::unwrap_failed
at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/result.rs:1749:5
rust-analyzer version: 65fbe0a 2022-04-18 nightly, and 65fbe0a 2022-04-18 stable. Was not in previous stable release.
rustc version: rustc 1.61.0-nightly (5f3700105 2022-03-22)
relevant settings:
Can be reproduced with this project: https://github.com/model-checking/kani
Notably uses these rust-analyzer settings in vscode:
"rust-analyzer.rustcSource": "discover",
This, together with a rust-toolchain.toml
specifying the above nightly release, supports src/kani-compiler/Cargo.toml
which includes:
[package.metadata.rust-analyzer]
# This package uses rustc crates.
rustc_private=true
Cause
The line of code triggering the panic was introduced with #11964
I wonder if possibly that line of code should be rustc_workspace[pkg]
and not cargo[pkg]
?
Temporary workaround
Removing "rust-analyzer.rustcSource": "discover",
from vscode config removes my ability to jump to rustc source code, but stops the crash loop.