Skip to content

Unable to fall through past $:lifetime matcher #51477

Closed
@dtolnay

Description

@dtolnay

This is similar to the same buggy behavior we saw for $:ident matchers fixed in 1.20.0.

For example in Rust 1.19 the following code fails to compile with the message "expected ident, found @", but correctly prints ident followed by other as of 1.20.

macro_rules! m {
    ($ident:ident) => { println!("ident"); };
    ($other:tt) => { println!("other"); };
}

fn main() {
    m!(ident);
    m!(@);
}

The $:lifetime matcher is currently broken in the same way.

macro_rules! m {
    ($lifetime:lifetime) => { println!("lifetime"); };
    ($other:tt) => { println!("other"); };
}

fn main() {
    m!('lifetime);
    m!(@);
}
error: expected a lifetime, found `@`
 --> src/main.rs:8:8
  |
8 |     m!(@);
  |        ^

rustc 1.28.0-nightly (2a00629 2018-06-09)

@sgrif @durka

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.T-langRelevant to the language 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