Try to recover from a =>
-> =
or ->
typo in a match arm
This commit is contained in:
parent
edebf77e00
commit
cf19131cb3
4 changed files with 67 additions and 1 deletions
|
@ -2322,7 +2322,21 @@ impl<'a> Parser<'a> {
|
|||
None
|
||||
};
|
||||
let arrow_span = this.token.span;
|
||||
this.expect(&token::FatArrow)?;
|
||||
if let Err(mut err) = this.expect(&token::FatArrow) {
|
||||
// We might have a `=>` -> `=` or `->` typo (issue #89396).
|
||||
if let token::Eq | token::RArrow = this.token.kind {
|
||||
err.span_suggestion(
|
||||
this.token.span,
|
||||
"try using a fat arrow here",
|
||||
"=>".to_string(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
err.emit();
|
||||
this.bump();
|
||||
} else {
|
||||
return Err(err);
|
||||
}
|
||||
}
|
||||
let arm_start_span = this.token.span;
|
||||
|
||||
let expr = this.parse_expr_res(Restrictions::STMT_EXPR, None).map_err(|mut err| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue