Skip to content

Trailing semicolon silently ignored in expr macro #33953

Open
@mahkoh

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 ().

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