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
I’ll trace macro-call completion handling, add a focused regression test for this fixture, then implement and run the narrow test suite.
- Assistant
rgis unavailable in this checkout, so I’m switching to targetedfind/grepsearches and keeping the investigation scoped to completion and macro-expansion crates. - Assistant
The failure is at the second expansion layer:
$ibecomes the path ofbar!(), and the speculative completion marker changes that path tobarcomplete_me!(). The code currently treats the differing macro paths as an inconsistent expansion and discards completion. I’m changing that case to stop expansion at the macro path—where normal path completion can resolvebar—while retaining the inconsistency guard for unrelated differences. - Assistant
The regression still reproduces, so the path-mismatch branch is not the first failure point. I’m narrowing this through the token-tree selection logic; the likely issue is that completion in a call’s path has no enclosing argument token tree, causing expansion to abort before the path comparison.
- Assistant
The completion now reaches the correct expanded layer and offers
baras a macro-path replacement (without adding another!, since the invocation already contains one). I’ve aligned the snapshot with the normal expression-scope candidates and am running the fullide-completioncrate tests to catch regressions.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →
- fable-5Compare side by side →