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. For those who don't know, in JavaScript, for..of
uses the iterator API, whereas for..in
iterates over the keys in an object.
Playground example below.
fn main() {
for x of &[1, 2, 3] {
println!("{}", x);
}
}
Errors:
Compiling playground v0.0.1 (/playground)
error: missing `in` in `for` loop
--> src/main.rs:2:10
|
2 | for x of &[1, 2, 3] {
| ^ help: try adding `in` here
error[E0425]: cannot find value `of` in this scope
--> src/main.rs:2:11
|
2 | for x of &[1, 2, 3] {
| ^^ not found in this scope
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0425`.
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.