rust-lang / rust-lang/rust-analyzer

Wrong macro expansion

Open
#18,571 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

rust-analyzer version: 0.3.2196-standalone

rustc version: (eg. output of rustc -V)

editor or extension: v0.3.2196

relevant settings: all unset

repository link (if public, optional): rust-enumeration

code snippet to reproduce: I do not know how to make a minimized reproducible example. tests/test.rs reports an error with "cannot define inherent impl on foreign type" and "unexpected token in input" from the macro invocation in line 56~60. However, cargo test runs fine without reporting any error. While attempting to reproduce the issue, you may need to modify the file (e.g. enter a new line and delete it) as the error may not be reported. Attempting to inline macro will result in missing tokens. I do not know if this is only reproducible on my machine.

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

Start with the linked rust-enumeration repository and inspect tests/test.rs, especially the macro invocation around lines 56–60. Reproduce the reported diagnostics in rust-analyzer, compare them with the successful cargo test run, and determine whether editing the file or inlining the macro changes the result. Done means the false errors and missing-token behavior are resolved for this reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.