Skip to content

Unable to fall through past $:lifetime matcher #51477

Closed
@dtolnay

Description

@dtolnay
Member

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

Activity

added
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
C-bugCategory: This is a bug.
T-langRelevant to the language team
on Jun 10, 2018
dtolnay

dtolnay commented on Jun 10, 2018

@dtolnay
MemberAuthor

The ident issue was #27832, so mentioning @kennytm who fixed that one in #42913. Would you be interested in taking a look at this similar case?

kennytm

kennytm commented on Jun 10, 2018

@kennytm
Member

Duplicate of #50903. @jrlusby should still be working on it I think?

dtolnay

dtolnay commented on Jun 10, 2018

@dtolnay
MemberAuthor

Thanks! Let's continue to track this as part of #50903.

added a commit that references this issue on Jun 11, 2018

Auto merge of #51480 - dtolnay:lifetime, r=kennytm

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @kennytm@dtolnay

      Issue actions

        Unable to fall through past $:lifetime matcher · Issue #51477 · rust-lang/rust