Skip to content

Commit ad088ef

Browse files
sjwang05estebank
andauthored
Try to reduce false positives
Co-authored-by: Esteban Kuber <[email protected]>
1 parent 1b53936 commit ad088ef

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,10 +611,12 @@ impl<'a> Parser<'a> {
611611
let mut err = self.struct_span_err(self.token.span, msg_exp);
612612

613613
// Look for usages of '=>' where '>=' was probably intended
614-
if self.token == token::FatArrow {
614+
if self.token == token::FatArrow
615+
&& expected.iter().any(|tok| matches!(tok, TokenType::Token(TokenKind::Le)))
616+
{
615617
err.span_suggestion(
616618
self.token.span,
617-
"you probably meant to write a \"greater than or equal to\" comparison",
619+
"you might have meant to write a \"greater than or equal to\" comparison",
618620
">=",
619621
Applicability::Unspecified,
620622
);

tests/ui/parser/eq-gt-to-gt-eq.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
// run-rustfix
12
// Check that we try to correct `=>` to `>=` in conditions.
3+
#![allow(unused)]
24

35
fn main() {
46
let a = 0;

0 commit comments

Comments
 (0)