rust-lang / rust-lang/rust-analyzer

Trying to access lsp with {} {} pattern in print macros(format!, println!, print!) causes rust-analyzer to crash

Open
#22,928 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

rust-analyzer version: rust-analyzer 2026-06-15

rustc version: rustc 1.95.0 (59807616e 2026-04-14) (built from a source tarball)

editor or extension: VSCode w/ rust-analyzer extension(Plain) & Neovim w/ nvim-lspconfig (Plain)

relevant settings: Standard install of rust-analyzer & rust toolchain via Nix package manager(NixOS)

code snippet to reproduce:

fn display_something() {
   println!("{} {}", 3,) ;
}

When having such snippet of code in an unsaved file, and trying to access lsp somewhere inside of the file causes rust-analyzer to crash

Neovim output:

rust_analyzer: -32603: request handler panicked: field FieldIndex(4294967295) out of range: (&'{region error} i32,)

VsCode output

thread 'Worker3' (1858481) panicked at crates/hir-ty/src/mir.rs:1276:40:
field FieldIndex(4294967295) out of range: (&'{region error} i32,)
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: hir_ty::mir::PlaceTy::field_ty
   3: hir_ty::mir::PlaceTy::projection_ty
   4: hir_ty::mir::borrowck::moved_out_of_ref::{{closure}}
   5: <hir_ty::mir::borrowck::_::borrowck_query_Configuration_ as salsa::function::Configuration>::execute::inner_::{{closure}}
   6: <hir_ty::mir::borrowck::_::borrowck_query_Configuration_ as salsa::function::Configuration>::execute
   7: salsa::function::execute::<impl salsa::function::IngredientImpl<C>>::execute
   8: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch_cold
   9: hir_ty::mir::borrowck::borrowck_query
  10: <DB as hir_ty::db::HirDatabase>::borrowck
  11: hir::DefWithBody::diagnostics
  12: hir::ModuleDef::diagnostics
  13: hir::Module::diagnostics
  14: ide_diagnostics::semantic_diagnostics
  15: ide_diagnostics::full_diagnostics
  16: salsa::cancelled::Cancelled::catch
  17: std::thread::local::LocalKey<T>::with
  18: ide::Analysis::assists_with_fixes
  19: rust_analyzer::handlers::request::handle_code_action
  20: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stacktrace:
   0: borrowck_query(Id(5a4b3)) -> (R4229, Durability::LOW)
             at crates/hir-ty/src/mir/borrowck.rs:136

additional context:
   0: 
version: 2026-06-15
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/paul/projects/todo_app/src/main.rs",
            query: None,
            fragment: None,
        },
    },
    range: Range {
        start: Position {
            line: 114,
            character: 1,
        },
        end: Position {
            line: 114,
            character: 1,
        },
    },
    context: CodeActionContext {
        diagnostics: [],
        only: None,
        trigger_kind: Some(
            Automatic,
        ),
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
}

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 crash with the println!("{} {}", 3,) snippet, then trigger an LSP code-action request in the unsaved file. Start at crates/hir-ty/src/mir.rs:1276 and the borrowck query at crates/hir-ty/src/mir/borrowck.rs:136; done means the request no longer panics for this malformed format-macro pattern.

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
Active
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.