Skip to content
TheChatArchiveThe Chat Archive
GLMz-ai/glm-5.2· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Cannot complete macro path in macro <!-- Troubleshooting guide:…

  1. 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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. GLM Assistant

    I'll start by exploring the repository structure to understand the codebase and find the relevant code for macro path completion.

  3. GLM Assistant

    I'll start by exploring the repository structure.

  4. GLM Assistant

    Let me explore the repository structure further to understand the codebase.

  5. GLM Assistant

    The issue is about macro path completion within a macro. Let me explore the ide-completion crate.

  6. GLM Assistant

    Let me look at how macro completion works. Let me search for relevant code.

  7. GLM Assistant

    I need to make single tool calls. Let me search for macro completion code.

  8. GLM Assistant

    Let me look at the context analysis to understand how completion context is determined for macro call arguments.

  9. GLM Assistant

    Let me look at the macro expansion logic in analysis.rs more closely.

  10. GLM Assistant

    Let me understand the issue better by creating a test that reproduces it. Let me look at how existing completion tests are structured.

  11. GLM Assistant

    Let me look at the test in_macro_expr_frag to understand the existing test structure for macro completions.

  12. GLM Assistant

    Let me look at how the check function works for completion tests.

  13. GLM Assistant

    Let me create a test to reproduce the issue.

  14. GLM Assistant

    Let me create a temporary test to reproduce the issue.

  15. GLM Assistant

    Let me add a test to the expression.rs test file temporarily and run it.

  16. GLM Assistant

    Let me check if there's a rust-toolchain file or a specific nightly requirement.

  17. GLM Assistant

    The test passed with an empty expectation, which confirms the issue - no completions are produced. Let me verify by printing the actual output.

  18. GLM Assistant

    I need to add my module to the tests.rs. Let me add mod expression_repro; after mod expression;.

  19. GLM Assistant

    I need completion_list to be a public function. Let me check its visibility.

  20. GLM Assistant

    I need to make completion_list accessible. Let me change my test file to use crate::tests::completion_list instead since it's pub(crate).

  21. GLM Assistant

    The actual completions are empty, confirming the issue. Now let me understand how the macro expansion-based completion works. Let me look at the expansion processing code.

  22. GLM Assistant

    Let me look at the beginning of the analysis.rs to understand the main flow.

  23. GLM Assistant

    Let me look at how expand_and_analyze is called and how the speculative file is built.

  24. GLM Assistant

    Let me add some debug tracing to understand what's happening during expansion.

  25. GLM Assistant

    Let me add some debug eprintln to understand. Let me look at the tts variable. Let me look at lines 256-379.

  26. GLM Assistant

    Let me add debug tracing to understand what's happening.

  27. GLM Assistant

    The eprintln inside the match tuple caused a syntax issue. Let me fix it.

  28. GLM Assistant

    The eprintln returns () so it becomes (() , expand, speculative). The match arms expect (Option<...>, Option<...>). This is a type mismatch. Let me move the eprintln out of the match.

  29. GLM Assistant

    The fake_ident_token is used later? Let me check if it's used after the match. Actually it was moved into the match. Let me check the rest of the function. It's only used in the speculative_expand call. But wait, the original code used fake_ident_token directly in the match tuple. Now I clone it. That should be fine. But is fake_ident_token used after? Let me check.

    Actually, in the original code, fake_ident_token was moved into speculative_expand_macro_call. The function returns after this match. So cloning shouldn't be an issue. Let me compile.

  30. GLM Assistant

    There's still a compile error. Let me see the full error.

  31. GLM Assistant

    Let me move the debug eprintln after tts is destructured.

  32. GLM Assistant

    The expansion succeeds but the recursion into bar!() fails. Let me look at is_inside_macro_call.

  33. GLM Assistant

    Let me look at the kind_macro_call and how NameRefKind is determined for macro call paths.

  34. GLM Assistant

    The expansion of foo!(bar) succeeds, producing bar!(), and the cursor maps to bar on the macro path. But the recursion fails because is_inside_macro_call returns true for the path token. Let me look at the git history of this check.

  35. GLM Assistant

    Let me look at the old might_be_inside_macro_call implementation before the rename.

  36. GLM Assistant

    Let me test a simpler scenario - macro path completion directly (without nesting).

  37. GLM Assistant

    The direct macro path completion works (bar$0!()), but the nested one (foo!(bar$0)) doesn't. This confirms the issue is in the expansion recursion. Let me check the other callers of is_inside_macro_call to understand if I should change it directly or add a targeted fix.

  38. GLM Assistant

    I'll go with a targeted fix in expand_maybe_stop. Let me first remove the debug eprintlns.

  39. GLM Assistant

    Now let me implement the fix. I'll modify the base case to also allow stopping when the token is on the path of a macro call.

  40. GLM Assistant

    Now let me run the reproduction test to see if the fix works.

  41. GLM Assistant

    The nested case now completes bar and foo macros. The fix works. Let me test more edge cases.

  42. GLM Assistant

    All edge cases work correctly. Now let me run the full ide-completion test suite to make sure I didn't break anything.

  43. GLM Assistant

    I still have the repro test in expression.rs. Let me remove that too.

  44. GLM Assistant

    All 732 tests pass. Now let me add a proper test for this fix in the expression.rs test file, matching the existing conventions.

  45. GLM Assistant

    Let me find the end of the in_macro_expr_frag test to add a new test after it.

  46. GLM Assistant

    The new test passes. Let me run the full ide-completion test suite once more to confirm nothing is broken.

  47. GLM Assistant

    All 733 tests pass. Let me also run the broader ide crate tests to ensure nothing in dependent crates breaks.

  48. GLM Assistant

    Let me also run the ide-db and ide-ssr tests since they use is_inside_macro_call indirectly (though I didn't change that function).

  49. GLM Assistant

    All tests pass. Let me review the final changes.

  50. GLM Assistant

    The changes look clean. Let me clean up temp files and do a final verification.

  51. GLM Assistant

    Let me run the final full test suite to confirm everything passes.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.