feat: implement error recovery in expected_ident_found
This commit is contained in:
parent
b4e17a5098
commit
05b5046633
8 changed files with 184 additions and 78 deletions
|
@ -1181,7 +1181,7 @@ impl<'a> Parser<'a> {
|
|||
defaultness: Defaultness,
|
||||
) -> PResult<'a, ItemInfo> {
|
||||
let impl_span = self.token.span;
|
||||
let mut err = self.expected_ident_found();
|
||||
let mut err = self.expected_ident_found_err();
|
||||
|
||||
// Only try to recover if this is implementing a trait for a type
|
||||
let mut impl_info = match self.parse_item_impl(attrs, defaultness) {
|
||||
|
@ -1776,7 +1776,7 @@ impl<'a> Parser<'a> {
|
|||
Err(err) => {
|
||||
err.cancel();
|
||||
self.restore_snapshot(snapshot);
|
||||
self.expected_ident_found()
|
||||
self.expected_ident_found_err()
|
||||
}
|
||||
}
|
||||
} else if self.eat_keyword(kw::Struct) {
|
||||
|
@ -1792,11 +1792,11 @@ impl<'a> Parser<'a> {
|
|||
Err(err) => {
|
||||
err.cancel();
|
||||
self.restore_snapshot(snapshot);
|
||||
self.expected_ident_found()
|
||||
self.expected_ident_found_err()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let mut err = self.expected_ident_found();
|
||||
let mut err = self.expected_ident_found_err();
|
||||
if self.eat_keyword_noexpect(kw::Let)
|
||||
&& let removal_span = self.prev_token.span.until(self.token.span)
|
||||
&& let Ok(ident) = self.parse_ident_common(false)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue