Don't silently eat label before block in block-like expr
This commit is contained in:
@@ -2468,11 +2468,15 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
|
||||
pub(crate) fn maybe_recover_unexpected_block_label(&mut self) -> bool {
|
||||
let Some(label) = self.eat_label().filter(|_| {
|
||||
self.eat(&token::Colon) && self.token.kind == token::OpenDelim(Delimiter::Brace)
|
||||
}) else {
|
||||
// Check for `'a : {`
|
||||
if !(self.check_lifetime()
|
||||
&& self.look_ahead(1, |tok| tok.kind == token::Colon)
|
||||
&& self.look_ahead(2, |tok| tok.kind == token::OpenDelim(Delimiter::Brace)))
|
||||
{
|
||||
return false;
|
||||
};
|
||||
}
|
||||
let label = self.eat_label().expect("just checked if a label exists");
|
||||
self.bump(); // eat `:`
|
||||
let span = label.ident.span.to(self.prev_token.span);
|
||||
let mut err = self.struct_span_err(span, "block label not supported here");
|
||||
err.span_label(span, "not supported here");
|
||||
|
||||
Reference in New Issue
Block a user