Skip to content

Commit 3a1828f

Browse files
committed
Consider tt as a "simple token".
This means a matcher will be accepted if it only contains tokens, `ident` or `tt` NT matchers, or delimited/sequences of them. This is valid beacuse `tt` will never start matching more input that matches the second matcher.
1 parent 02f1e17 commit 3a1828f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/libsyntax/ext/tt/macro_rules.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -837,10 +837,13 @@ fn check_matcher_firsts(cx: &ExtCtxt, ma: &[TokenTree], mb: &[TokenTree],
837837
}
838838
}
839839

840-
// checks that a matcher does not contain any NT except ident
840+
// checks that a matcher does not contain any NT except ident or TT.
841+
// that is, that it will never start matching new input
841842
fn only_simple_tokens(m: &[TokenTree]) -> bool {
842843
m.iter().all(|tt| match *tt {
843-
TokenTree::Token(_, MatchNt(_, nt)) => nt.name.as_str() == "ident",
844+
TokenTree::Token(_, MatchNt(_, nt)) =>
845+
nt.name.as_str() == "ident" ||
846+
nt.name.as_str() == "tt",
844847
TokenTree::Token(..) => true,
845848
TokenTree::Delimited(_, ref delim) => only_simple_tokens(&delim.tts),
846849
TokenTree::Sequence(_, ref seq) => only_simple_tokens(&seq.tts)

0 commit comments

Comments
 (0)