about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/expr.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-10-05 04:13:35 +0000
committerbors <bors@rust-lang.org>2021-10-05 04:13:35 +0000
commita804c4b1123ae665a8d4f726524109c49efac5b6 (patch)
treeda839dfc8b539262cc668687d423aee93cd2002a /compiler/rustc_parse/src/parser/expr.rs
parent003d8d3f56848b6f3833340e859b089a09aea36a (diff)
parent2ae8ced803a6852ef309b7f1c3af6977f87d5368 (diff)
downloadrust-a804c4b1123ae665a8d4f726524109c49efac5b6.tar.gz
rust-a804c4b1123ae665a8d4f726524109c49efac5b6.zip
Auto merge of #89545 - workingjubilee:rollup-ooxf3p2, r=workingjubilee
Rollup of 15 pull requests

Successful merges:

 - #87993 (Stabilize try_reserve)
 - #88090 (Perform type inference in range pattern)
 - #88780 (Added abs_diff for integer types.)
 - #89270 (path.push() should work as expected on windows verbatim paths)
 - #89413 (Correctly handle supertraits for min_specialization)
 - #89456 (Update to the final LLVM 13.0.0 release)
 - #89466 (Fix bug with query modifier parsing)
 - #89473 (Fix extra `non_snake_case` warning for shorthand field bindings)
 - #89474 (rustdoc: Improve doctest pass's name and module's name)
 - #89478 (Fixed numerus of error message)
 - #89480 (Add test for issue 89118.)
 - #89487 (Try to recover from a `=>` -> `=` or `->` typo in a match arm)
 - #89494 (Deny `where` clauses on `auto` traits)
 - #89511 (:arrow_up: rust-analyzer)
 - #89536 (update Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
-rw-r--r--compiler/rustc_parse/src/parser/expr.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index c5417ea23f2..79f46be73f6 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -2322,7 +2322,24 @@ 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 TokenKind::FatArrow
+                    .similar_tokens()
+                    .map_or(false, |similar_tokens| similar_tokens.contains(&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| {