Skip to content

Trailing semicolon silently ignored in expr macro #33953

Description

@mahkoh
fn main() {
    macro_rules! a {
        ($e:expr) => { $e; }
    }
    a!(true)
}

Error: Expected (), found bool

But:

fn main() {
    macro_rules! a {
        ($e:expr) => { $e; }
    }
    a!(true);  // <-- semicolon
}

does not warn that the ; is ignored.

So either

  • there should be a warning that the ; has no effect in the macro, or
  • the ; inside the macro should turn the expression into ().

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-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions