rust-lang / rust-lang/rust-analyzer

rust-analyzer reports errors when dbg! macros are present in saved code

Open
#17,261 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Example:

use std::env;

fn main() {
    let args: Vec<String> = env::args().collect();
    dbg!(args);
}

Screenshots:

image

Detail Description:

Panic context:

version: 0.3.1958-standalone (5bf2f85c8 2024-05-09)
request: textDocument/inlayHint InlayHintParams {
work_done_progress_params: WorkDoneProgressParams {
work_done_token: None,
},
text_document: TextDocumentIdentifier {
uri: Url {
scheme: "file",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/e%3A/study/rust/minigrep/src/main.rs",
query: None,
fragment: None,
},
},
range: Range {
start: Position {
line: 0,
character: 0,
},
end: Position {
line: 6,
character: 0,
},
},
}

thread 'Worker' panicked at C:\Users\runneradmin.cargo\registry\src\index.crates.io-6f17d22bba15001f\line-index-0.1.1\src\lib.rs:111:35:
invalid offset
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:645
1: core::panicking::panic_fmt
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\panicking.rs:72
2: core::panicking::panic_display<ref$<str$> >
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\panicking.rs:197
3: core::panicking::panic_str
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\panicking.rs:172
4: core::option::expect_failed
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\option.rs:1995
5: rust_analyzer::lsp::to_proto::inlay_hint
6: alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec>::from_iter
7: core::iter::adapters::try_process
8: rust_analyzer::handlers::request::handle_inlay_hints
9: std::panicking::try
10: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
[Error - 14:07:05] Request textDocument/inlayHint failed.
Message: request handler panicked: invalid offset
Code: -32603
Panic context:

version: 0.3.1958-standalone (5bf2f85c8 2024-05-09)
request: textDocument/inlayHint InlayHintParams {
work_done_progress_params: WorkDoneProgressParams {
work_done_token: None,
},
text_document: TextDocumentIdentifier {
uri: Url {
scheme: "file",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/e%3A/study/rust/minigrep/src/main.rs",
query: None,
fragment: None,
},
},
range: Range {
start: Position {
line: 0,
character: 0,
},
end: Position {
line: 6,
character: 0,
},
},
}

thread 'Worker' panicked at C:\Users\runneradmin.cargo\registry\src\index.crates.io-6f17d22bba15001f\line-index-0.1.1\src\lib.rs:111:35:
invalid offset
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:645
1: core::panicking::panic_fmt
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\panicking.rs:72
2: core::panicking::panic_display<ref$<str$> >
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\panicking.rs:197
3: core::panicking::panic_str
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\panicking.rs:172
4: core::option::expect_failed
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\option.rs:1995
5: rust_analyzer::lsp::to_proto::inlay_hint
6: alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec>::from_iter
7: core::iter::adapters::try_process
8: rust_analyzer::handlers::request::handle_inlay_hints
9: std::panicking::try
10: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
[Error - 14:07:07] Request textDocument/inlayHint failed.
Message: request handler panicked: invalid offset
Code: -32603

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the saved Rust example containing dbg! and a textDocument/inlayHint request. Start by tracing rust_analyzer::handlers::request::handle_inlay_hints through rust_analyzer::lsp::to_proto::inlay_hint, with the line-index invalid-offset panic as the symptom. Done means inlay-hint requests no longer panic and the reported example produces usable results.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.