Closed
Description
Been working in JavaScript a lot lately and find myself accidentally typing this a lot. It would be nice to automatically detect this and offer a proper fix. Lots of languages use this syntax in addition to JavaScript so it seems like a reasonable error to make.
Playground example below.
#![feature(test)]
use std::hint::black_box;
fn main() {
if 1 === black_box(1) {
println!("yup!");
} else if 2 !== black_box(2) {
println!("nope!");
}
}
Errors:
Compiling playground v0.0.1 (/playground)
error: expected expression, found `=`
--> src/main.rs:4:12
|
4 | if 1 === black_box(1) {
| ^ expected expression
warning: unused import: `std::hint::black_box`
--> src/main.rs:2:5
|
2 | use std::hint::black_box;
| ^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error: aborting due to previous error; 1 warning emitted
error: could not compile `playground`.
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: The lexing & parsing of Rust source code to an ASTArea: Suggestions generated by the compiler applied by `cargo fix`Category: An issue proposing an enhancement or a PR with one.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.