ISSUE DESCRIPTION Cannot complete macro path in macro <!-- Troubleshooting guide:…
- User
ISSUE DESCRIPTION
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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /rust-analyzer, current file: none) bash-$
- Assistant
I'll start by exploring the repository structure and searching for relevant completion/macro code to understand how path completion works inside macros.
- Assistant
Let me search for relevant completion tests related to macros.
- Assistant
Let me look at the test structure and search for similar issues.
- Assistant
The
!is being interpreted. Let me escape it. - Assistant
Interesting - rg is not found when I chain with && after ls. Let me try grep instead.
- Assistant
Let me look at the special tests and macro-related completion code.
- Assistant
Looking at the simple macro call completion test and related context handling.
- Assistant
I'll search for how completions handle identifiers inside macro calls and path kinds.
- Assistant
Let me look at how path completion is determined and how macro arguments work.
- Assistant
Looking at how analysis decides path kinds inside macros, which is central to this bug.
- Assistant
I'll try reproducing the issue with a temporary test.
- Assistant
I'll add a temporary test to reproduce the issue and run it.
- Assistant
Let me add a temporary test after this one.
- Assistant
Let me insert a test for the issue.
- Assistant
Now let me run this test.
- Assistant
Need to set up rustup.
- Assistant
There's a specific rust-version. Let me check how to set up the toolchain.
- Assistant
There's a toolchain available. Let me set it up.
- Assistant
Confirmed: completions are empty. I'll try related variants and dig into the expansion/analysis path.
- Assistant
Let me run the test again.
- Assistant
I'll reorder the cases so each variant is tested on its own.
- Assistant
Let me run with UPDATE_EXPECT to see the actual values.
- Assistant
Meanwhile check how the direct case looks once fully updated.
- Assistant
I'll inspect speculative expansion and how macro call paths are analyzed after expansion.
- Assistant
Let me read the rest of the expand function for macro_call handling.
- Assistant
Looking at how MacroCall and token tree ancestry is detected around the cursor.
- Assistant
Checking how
is_inside_macro_callis defined and used. - Assistant
Let me look atthat function.
- Assistant
Checking how
is_inside_macro_callis used elsewhere and the base-case intent. - Assistant
Checking the old heuristics and git history for more context.
- Assistant
Checking how analyze handles tokens inside unexpanded macro token trees.
- Assistant
Reading more of the analyze function to see name_like handling.
- Assistant
Looking at the current
is_inside_macro_callimplementation to craft the fix. - Assistant
The docstring says we should only treat tokens in the macro input as inside — the path of a MacroCall isn't input. Fixing that.
- Assistant
I'll tighten the comment and restore proper test expectations.
- Assistant
Updating the tests to cover the issue properly.
- Assistant
Cleaning up the test comment and spacing before running it.
- Assistant
I accidentally removed the
#[test]attribute — restoring it. - Assistant
Running the test to verify the fix.
- Assistant
The fix works. Updating test expectations to include
fooas well. - Assistant
Running the target test and broader related suites.
- Assistant
Running the full ide-completion suite and checking for related hir tests.
- Assistant
All 733 ide-completion tests passed. Running broader related crate tests next.
- Assistant
Verifying the exact issue snippet, then cleaning up.
- Assistant
Removing the duplicate brace.
- Assistant
Need a blank line before #[test].
- Assistant
Now run the test again.
- Assistant
Checking how check_no_kw filters completions.
- Assistant
Aligning the issue snippet expectation with the full completion list.
- Assistant
Running the tests one more time to confirm.
- Assistant
Checking the final diff for cleanliness.
- Assistant
Running the full ide-completion suite once more before submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.