Skip to content
TheChatArchiveThe Chat Archive
composer-2.5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

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

  1. 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.

  2. Assistant

    Investigating macro path completion inside macro invocations — searching the codebase for how completions are resolved in that context.

  3. Assistant

    Implementing the fix: speculative expansion fails when the inner macro name includes the completion marker, so we'll stop at the mapped expansion level instead.

  4. Assistant

    Refining the fix: only stop early when the speculative macro call path itself contains the completion marker (e.g. barraCompletionMarker!()), not when the marker is only in macro arguments.

  5. Assistant

    Fixed macro path completion when an ident metavariable is spliced into a macro invocation path (e.g. $i!()).

    Root cause

    When completing inside foo!(bar$0) where foo expands to $i!():

    1. Speculative expansion correctly mapped the cursor into barraCompletionMarker!() in the expanded file.
    2. Completion then tried to expand that inner macro call further.
    3. That failed because the speculative path (barraCompletionMarker) doesn't match the real path (bar).
    4. The whole expansion was discarded, so CompletionContext::new returned None and no completions were offered.

    Fix

    In crates/ide-completion/src/context/analysis.rs, when further expansion fails but the mapped token is part of a speculative macro call path (completion marker in the macro path, not in macro arguments), stop at the current expansion level instead of giving up.

    This preserves existing behavior for cases like m!(v$0) where the marker is passed as a macro argument to helper!($v) and completion should continue at the $v expression site.

    Tests

    Added completes_macro_path_in_macro in crates/ide-completion/src/tests/special.rs covering:

    • foo!(bar$0) — partial name
    • foo!($0) — empty argument
    • Applying the bar completion

    All 733 ide-completion tests pass.

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