Skip to content

Commit d0dda18

Browse files
authored
Rollup merge of #70768 - petrochenkov:macambig, r=Centril,mark-i-m
macro_rules: `NtLifetime` cannot start with an identifier Fixes #70446
2 parents 590cb8b + 106b30e commit d0dda18

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/librustc_expand/mbe/macro_parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ fn may_begin_with(token: &Token, name: Name) -> bool {
768768
/// Checks whether the non-terminal may contain a single (non-keyword) identifier.
769769
fn may_be_ident(nt: &token::Nonterminal) -> bool {
770770
match *nt {
771-
token::NtItem(_) | token::NtBlock(_) | token::NtVis(_) => false,
771+
token::NtItem(_) | token::NtBlock(_) | token::NtVis(_) | token::NtLifetime(_) => false,
772772
_ => true,
773773
}
774774
}

src/test/ui/macros/issue-70446.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// check-pass
2+
3+
macro_rules! foo {
4+
($(: $p:path)? $(: $l:lifetime)? ) => { bar! {$(: $p)? $(: $l)? } };
5+
}
6+
7+
macro_rules! bar {
8+
($(: $p:path)? $(: $l:lifetime)? ) => {};
9+
}
10+
11+
foo! {: 'a }
12+
13+
fn main() {}

0 commit comments

Comments
 (0)