Open
Description
Given the following code:
let is_greater = 5 => 3;
The current output is:
Compiling playground v0.0.1 (/playground)
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `=>`
--> src/main.rs:2:24
|
2 | let is_greater = 5 => 3;
| ^^ expected one of `.`, `;`, `?`, `else`, or an operator
error: could not compile `playground` due to previous error
This had me very confused for a surprising amount of time. It would be nice if the compiler would give a suggestion to replace =>
with >=
. In my opinion, this would help a lot for someone typing quickly, and would make it clear that the symbols were in reverse. It might also lead to some false positives, but I think it would still be nice to have.
The error is actually worse for macros:
macro_rules! accept_expr {
( $expr:expr ) => { $expr }
}
fn main() {
accept_expr!(5 => 3);
}
The current output for this macro is:
Compiling playground v0.0.1 (/playground)
error: no rules expected the token `=>`
--> src/main.rs:6:20
|
1 | macro_rules! accept_expr {
| ------------------------ when calling this macro
...
6 | accept_expr!(5 => 3);
| ^^ no rules expected this token in macro call
error: could not compile `playground` due to previous error
My suggestion it to simply add a help
section to both of the above errors, which would suggest replacing the =>
token with >=
.