Skip to content

[Rust] Macro improperly marked as invalid #3904

@Rapptz

Description

@Rapptz

What happened?

The following macro gives an erroneous source.rust meta.macro.rust invalid.illegal.rust scope:

macro_rules! test {
    ($($name:ident),+$(,)?) => {
        pub struct Foo {
            $(
                pub $name : Option<String>
            ),+
        }

        pub async fn thing() -> () {}
    }
}

image

From a cursory view in the repository and from testing it seems this is applied because of this rule

macro-semi-sep:
- include: comments
- match: ';'
scope: punctuation.terminator.rust
pop: true
- match: '(?=[})\]])'
pop: true
- match: '\S'
# This is intended to help make it evident when you forget a semicolon.
scope: invalid.illegal.rust

Adding the ; after the struct definition does make the scope go away but ironically it leads to invalid code since you can't have ; after a struct definition:

error: expected item, found `;`
  --> src/main.rs:15:2
   |
15 | };
   |  ^ help: remove this semicolon
   |
   = help: braced struct declarations are not followed by a semicolon

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions