Skip to content

bad diagnostic when macro tries to use stmt as expr #30597

Description

@durka

Given this macro:

macro_rules! foo {
    ($s:stmt) => { $s }
}

When called in expression context, for example println!("{}", foo!(42)), the error message refers to "unexpected token 42;", thereby conjuring a semicolon out of the ether. We aren't JS so we shouldn't conjure semicolons out of the ether :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions