Skip to content

Commit 2708486

Browse files
petrochenkovMark-Simulacrum
authored andcommitted
macro_rules: NtLifetime cannot start with an identifier
1 parent c1df9f0 commit 2708486

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
@@ -762,7 +762,7 @@ fn may_begin_with(token: &Token, name: Name) -> bool {
762762
/// Checks whether the non-terminal may contain a single (non-keyword) identifier.
763763
fn may_be_ident(nt: &token::Nonterminal) -> bool {
764764
match *nt {
765-
token::NtItem(_) | token::NtBlock(_) | token::NtVis(_) => false,
765+
token::NtItem(_) | token::NtBlock(_) | token::NtVis(_) | token::NtLifetime(_) => false,
766766
_ => true,
767767
}
768768
}

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)