Make sure that macros that didn't pass LHS checking are not expanded.
This avoids duplicate errors for things like invalid fragment specifiers, or parsing errors for ambiguous macros. Fixes #29231.
This commit is contained in:
parent
310d8996f4
commit
eb364e9c29
5 changed files with 93 additions and 42 deletions
|
@ -549,13 +549,8 @@ pub fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal {
|
|||
token::NtPath(Box::new(panictry!(p.parse_path(PathStyle::Type))))
|
||||
},
|
||||
"meta" => token::NtMeta(panictry!(p.parse_meta_item())),
|
||||
_ => {
|
||||
p.span_fatal_help(sp,
|
||||
&format!("invalid fragment specifier `{}`", name),
|
||||
"valid fragment specifiers are `ident`, `block`, \
|
||||
`stmt`, `expr`, `pat`, `ty`, `path`, `meta`, `tt` \
|
||||
and `item`").emit();
|
||||
panic!(FatalError);
|
||||
}
|
||||
// this is not supposed to happen, since it has been checked
|
||||
// when compiling the macro.
|
||||
_ => p.span_bug(sp, "invalid fragment specifier")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue