rust-lang / rust-lang/rust-analyzer

Request textDocument/inlayHint failed: invalid offset

Open
#18,881 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-inlay-hints A-macro C-bug I-panic
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

The error notification Request textDocument/inlayHint failed appears every time the below source is focused or modified.

use tracing::info;

pub fn main() {
    info!("Hello, world!");
}

Removing the call to info! stops the error.

rust-analyzer version: 0.4.2252-standalone (cd12ef8547 2025-01-07)

rustc version: rustc 1.86.0-nightly (243d2ca4d 2025-01-06)

editor or extension: VSCode extension 0.3.2253 (and current pre-release)

Panic context:
> 
version: 0.4.2252-standalone (cd12ef8547 2025-01-07)
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: "/d%3A/Development/XXX/crates/XXX/main.rs",
            query: None,
            fragment: None,
        },
    },
    range: Range {
        start: Position {
            line: 0,
            character: 0,
        },
        end: Position {
            line: 5,
            character: 0,
        },
    },
}

thread 'Worker' panicked at C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\line-index-0.1.2\src/lib.rs:111:35:
invalid offset
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf\library/std\src\panicking.rs:665
   1: core::panicking::panic_fmt
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf\library/core\src\panicking.rs:74
   2: core::panicking::panic_display
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf\library/core\src\panicking.rs:264
   3: core::option::expect_failed
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf\library/core\src\option.rs:2021
   4: rust_analyzer::lsp::to_proto::inlay_hint
   5: <alloc::vec::into_iter::IntoIter<T,A> as core::iter::traits::iterator::Iterator>::try_fold
   6: alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
   7: core::iter::adapters::try_process
   8: rust_analyzer::handlers::request::handle_inlay_hints
   9: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 5:09:58 AM] 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 panic with the provided Rust source and inlay-hint request. Start in rust_analyzer::handlers::request::handle_inlay_hints and rust_analyzer::lsp::to_proto::inlay_hint, then inspect the line-index 0.1.2 invalid-offset failure. Done means the example no longer causes an invalid offset panic when focused or modified.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.