rust-lang / rust-lang/rust-analyzer

Macro panics in rust-analyzer but doesn't panic in cargo build

Open
#19,487 1 comment 0 reactions 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

rust-analyzer version: rust-analyzer version: 0.3.2362-standalone (fb133c8c80 2025-03-29) [c:\Users\Tamaro.vscode\extensions\rust-lang.rust-analyzer-0.3.2362-win32-x64\server\rust-analyzer.exe]

rustc version: rustc 1.85.0 (4d91de4e4 2025-02-17)

editor or extension: VSCode 0.3.2362

repository link: https://github.com/tamaro-skaljic/rustc-vs-rust-analyzer

cd lib-test
cargo build

build successful

Image

rust analyzer in VS Code displays proc-macro panicked

Image

If lib_derive/src/lib.rs#L38 is replaced with panic!("{}", ident);

Image

looks like the macro is executed two times, 1. before the table macro is evaluated, 2. after the table macro is evaluated. At least we can say that rust-analyzer doesn't do the same thing as cargo build.

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 discrepancy in the linked rustc-vs-rust-analyzer repository by running cargo build in lib-test and observing the proc-macro result in VS Code. Inspect lib_derive/src/lib.rs around line 38 and compare the macro's behavior before and after the table macro is evaluated; done means explaining or correcting the differing rust-analyzer behavior without breaking the successful Cargo build.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, vscode
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.