-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add suggestions to EXPLICIT_[INTO_]ITER_LOOP
#1486
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
Conversation
Also reduces the highlighted span to the expr containing the `.[into_]iter()` call (so the suggestion is probably applicable by rustfix.) Fixes rust-lang#1484
Didn't hear anything from you, @mcarton, so here is my PR :) Changing this code once again reminded me of how crazy deeply indented everything in clippy is. Or maybe I just need a wider screen? |
for i in (10..0).map(|x| x * 2) { | ||
println!("{}", i); | ||
}*/ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason this was commented out before? Seems fine to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno. But 10..0
is an empty range so that's a bad example anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right. I'll just remove it, okay?
for _v in vec.iter() { } | ||
//~^ ERROR it is more idiomatic to loop over `&vec` | ||
//~| HELP to write this more concisely, try looping over | ||
//~| SUGGESTION &vec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually prefer to had a bit of context around the suggestion, just to be sure:
//~| SUGGESTION for _v in &vec {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is compile-test clever enough to pick this up even if my suggestion only contains &vec
? (Let's find out!)
Looks good 😄
I can display 91 columns on half a screen, but yeah, it might be hard to fit there :sad: |
Come on, the travis failure is |db| {⏎
- db.span_suggestion(arg.span,⏎
- "to write this more concisely, try looping over",⏎
- object.to_string());⏎
+ db.span_suggestion(arg.span, "to write this more concisely, try looping over", object.to_string());⏎
});⏎ How is that better? |
Lol, I reinstalled rustfmt an hour ago. Literally! This is my prompt when I scroll up (notice the time on the right):
But fine, I'll make you happy, Travis. |
Thanks! |
Also reduces the highlighted span to the expr containing the
.[into_]iter()
call (so the suggestion is probably applicable by rustfix.)Fixes #1484