Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect >= to => typo in comparisons #117245

Closed
estebank opened this issue Oct 26, 2023 · 1 comment · Fixed by #117303
Closed

Detect >= to => typo in comparisons #117245

estebank opened this issue Oct 26, 2023 · 1 comment · Fixed by #117303
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@estebank
Copy link
Contributor

estebank commented Oct 26, 2023

When encountering code like if 42 => 2 {}, we currently emit

error: expected `{`, found `=>`
 --> src/main.rs:2:10
  |
2 |    if 42 => 2 {}
  |          ^^ expected `{`
  |
note: the `if` expression is missing a block after this condition
 --> src/main.rs:2:7
  |
2 |    if 42 => 2 {}
  |       ^^

But it should be closer to

error: expected `{`, found `=>`
 --> src/main.rs:2:10
  |
2 |    if 42 => 2 {}
  |          ^^ expected `{`
  |
note: you likely meant to write a "greater than or equal to" comparison
 --> src/main.rs:2:7
  |
2 -    if 42 => 2 {}
2 +    if 42 >= 2 {}
  |
@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 26, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 26, 2023
@estebank estebank removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 26, 2023
@sjwang05
Copy link
Contributor

Hi! I'd like to try working on this issue if nobody else is currently.

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants