Auto merge of #62643 - estebank:parse-recovery-type-errs, r=petrochenkov
Do not emit type errors after parse error in last statement of block When recovering from a parse error inside a block, do not emit type errors generating on that block's recovered return expression. Fix #57383.
This commit is contained in:
commit
d82fd9ecd3
9 changed files with 42 additions and 61 deletions
|
@ -4675,6 +4675,9 @@ impl<'a> Parser<'a> {
|
|||
{
|
||||
e.emit();
|
||||
self.recover_stmt();
|
||||
// Don't complain about type errors in body tail after parse error (#57383).
|
||||
let sp = expr.span.to(self.prev_span);
|
||||
stmt.node = StmtKind::Expr(DummyResult::raw_expr(sp, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4692,8 +4695,7 @@ impl<'a> Parser<'a> {
|
|||
if self.eat(&token::Semi) {
|
||||
stmt = stmt.add_trailing_semicolon();
|
||||
}
|
||||
|
||||
stmt.span = stmt.span.with_hi(self.prev_span.hi());
|
||||
stmt.span = stmt.span.to(self.prev_span);
|
||||
Ok(Some(stmt))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue