Skip to content

Commit

Permalink
Rollup merge of #70768 - petrochenkov:macambig, r=Centril,mark-i-m
Browse files Browse the repository at this point in the history
macro_rules: `NtLifetime` cannot start with an identifier

Fixes #70446
  • Loading branch information
Dylan-DPC committed Apr 5, 2020
2 parents 590cb8b + 106b30e commit d0dda18
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 d0dda18

Please sign in to comment.