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>2023-12-27 17:26:12 +0000
committerbors <bors@rust-lang.org>2023-12-27 17:26:12 +0000
commita861c8965eaff66901710cc384a59f6b0b1a7700 (patch)
tree36c55cb6e53cc6ddcf4e7f83a2e4836a536ee181 /compiler/rustc_parse/src/parser/expr.rs
parent15755f38cd94f160713a6117829b0d1da2535b05 (diff)
parent97cf1c87bd98c13f4de91f7afbc971dba829ac92 (diff)
downloadrust-a861c8965eaff66901710cc384a59f6b0b1a7700.tar.gz
rust-a861c8965eaff66901710cc384a59f6b0b1a7700.zip
Auto merge of #117303 - sjwang05:issue-117245, r=estebank
Suggest `=>` --> `>=` in comparisons

Fixes #117245
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
-rw-r--r--compiler/rustc_parse/src/parser/expr.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index b76d67cf715..73bd19f34c1 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -2445,6 +2445,7 @@ impl<'a> Parser<'a> {
             }
         } else {
             let attrs = self.parse_outer_attributes()?; // For recovery.
+            let maybe_fatarrow = self.token.clone();
             let block = if self.check(&token::OpenDelim(Delimiter::Brace)) {
                 self.parse_block()?
             } else {
@@ -2469,6 +2470,15 @@ impl<'a> Parser<'a> {
                                 "you likely meant to continue parsing the let-chain starting here",
                             );
                         } else {
+                            // Look for usages of '=>' where '>=' might be intended
+                            if maybe_fatarrow.kind == token::FatArrow {
+                                err.span_suggestion(
+                                    maybe_fatarrow.span,
+                                    "you might have meant to write a \"greater than or equal to\" comparison",
+                                    ">=",
+                                    Applicability::MaybeIncorrect,
+                                );
+                            }
                             err.span_note(
                                 cond_span,
                                 "the `if` expression is missing a block after this condition",