Always error on invalid macro fragment specifiers

Fixes #21370.

unused-macro-with-follow-violation.rs was already handled correctly. That test
is just for good measure. :)
This commit is contained in:
Keegan McAllister
2015-02-25 17:11:36 -08:00
parent 880fb89bde
commit 65ea9110bd
3 changed files with 36 additions and 4 deletions

View File

@@ -334,6 +334,10 @@ fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token)
let tok = if let TtToken(_, ref tok) = *token { tok } else { unreachable!() };
// If T' is in the set FOLLOW(NT), continue. Else, reject.
match (&next_token, is_in_follow(cx, &next_token, frag_spec.as_str())) {
(_, Err(msg)) => {
cx.span_err(sp, &msg);
continue
}
(&Eof, _) => return Some((sp, tok.clone())),
(_, Ok(true)) => continue,
(next, Ok(false)) => {
@@ -343,10 +347,6 @@ fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token)
token_to_string(next)));
continue
},
(_, Err(msg)) => {
cx.span_err(sp, &msg);
continue
}
}
},
TtSequence(sp, ref seq) => {