Skip to content

Commit

Permalink
macro_rules: NtLifetime cannot start with an identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Apr 4, 2020
1 parent 49dc2f9 commit 106b30e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustc_expand/mbe/macro_parser.rs
Expand Up @@ -768,7 +768,7 @@ fn may_begin_with(token: &Token, name: Name) -> bool {
/// Checks whether the non-terminal may contain a single (non-keyword) identifier.
fn may_be_ident(nt: &token::Nonterminal) -> bool {
match *nt {
token::NtItem(_) | token::NtBlock(_) | token::NtVis(_) => false,
token::NtItem(_) | token::NtBlock(_) | token::NtVis(_) | token::NtLifetime(_) => false,
_ => true,
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/test/ui/macros/issue-70446.rs
@@ -0,0 +1,13 @@
// check-pass

macro_rules! foo {
($(: $p:path)? $(: $l:lifetime)? ) => { bar! {$(: $p)? $(: $l)? } };
}

macro_rules! bar {
($(: $p:path)? $(: $l:lifetime)? ) => {};
}

foo! {: 'a }

fn main() {}

0 comments on commit 106b30e

Please sign in to comment.