Cannot complete macro path in macro <!-- Troubleshooting guide:…
- User
Cannot complete macro path in macro
rust-analyzer version: rust-analyzer 0.4.2897-standalone
rustc version: rustc 1.97.0-nightly (36ba2c771 2026-04-23)
editor or extension: Vim
code snippet to reproduce:
macro_rules! bar { () => (); } macro_rules! foo { ($i:ident) => { $i!() }; } fn main() { foo!(bar$0); }Interface
No new interfaces are introduced.
- Assistant
Let me look at how this issue manifests. First, let me write a quick reproduction test to confirm the behavior.
- Assistant
Let me add a reproduction test to see the current (broken) behavior:
- Assistant
Now update the test expectation and run:
- Assistant
The fix works —
barandfoomacros are now completed. Let me see the full captured expectation: - Assistant
All green. Let me also run clippy on the changed crates:
- Assistant
The clippy warnings pre-exist on the clean tree — unrelated. Let me run the remaining dependent test suites for safety:
- Assistant
All suites pass. Let me review the final diff:
- Assistant
The fix is complete. Summary of what was done:
Root cause
For
foo!(bar$0)wherefoo!expands$iinto a macro path ($i!()), completion analysis works by recursively expanding macros while tracking the speculative completion token:foo!(bar<marker>)speculatively expands tobar<marker>!()— the mapped token lands in the macro path position of the nested call.- At that level,
expandincrates/ide-completion/src/context/analysis.rscan't expand further (the speculative call path doesn't resolve, and there's no ancestor at the path position).
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.