rust-analyzer: Shadowed macro causes macro-error

The first foo!(1); uses to the subsequent shadowed macro_rules! foo. Causing expected leaf: `,` rust-analyzer(macro-error). Performing “Go to Definition” confirms this, as the cursor jumps to the second macro_rules! foo.

fn main() {
    macro_rules! foo {
        ($a:expr) => {};
    }

    foo!(1);

    macro_rules! foo {
        ($a:expr, $b:expr) => {};
    }

    foo!(1, 2);
}

image

This issue must have been introduced lately, as a few weeks ago this was not an issue.

Issue exists on both stable and the latest nightly release:

  • rust-analyzer version: 2020-12-28 (1d53075)
  • rust-analyzer version: nightly (77ad203)

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 1
  • Comments: 17 (10 by maintainers)

Most upvoted comments

Oh, putting all that code into main makes a big difference. Local definitions are mostly not supported yet.

@edwin0cheng https://github.com/rust-analyzer/rust-analyzer/commit/8584d269262e73aa7c3ebe25b1d61483375de267 isn’t on master, you meant #7145.

@vallentin not really, you’d need to wait until tomorrow. Building from source isn’t that hard, though.

(I can’t reproduce it either)

Also, that’s a lovely issue report, I wish we had more of these.