Auto merge of #117303 - sjwang05:issue-117245, r=estebank
Suggest `=>` --> `>=` in comparisons Fixes #117245
This commit is contained in:
commit
a861c8965e
6 changed files with 230 additions and 0 deletions
|
@ -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",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue