Skip to content

macro expanding to nothing in match arm causes uninformative parse error #30128

Closed
@durka

Description

@durka

Failing code:

macro_rules! empty { () => () }

fn main() {
    match 42 {
        _ => empty!()
    };
}

The error is "unexpected token: <eof>" with a span of 1:1: 1:1.

Workaround:

macro_rules! empty { () => () }

fn main() {
    match 42 {
        _ => { empty!(); }
    };
}

Expected: the failing code either compiles or at least gives an error pointing at the problem.

Found by mohawk on IRC.

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