Skip to content

Conversation

killercup
Copy link
Contributor

Also reduces the highlighted span to the expr containing the .[into_]iter() call (so the suggestion is probably applicable by rustfix.)

Fixes #1484

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
@killercup
Copy link
Contributor Author

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);
}*/
}
Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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 {

Copy link
Contributor Author

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!)

@mcarton
Copy link
Contributor

mcarton commented Jan 28, 2017

Looks good 😄

Changing this code once again reminded me of how crazy deeply indented everything in clippy is.

I can display 91 columns on half a screen, but yeah, it might be hard to fit there :sad:

@mcarton
Copy link
Contributor

mcarton commented Jan 28, 2017

Come on, the travis failure is rustfmt requesting

                                    |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?

@killercup
Copy link
Contributor Author

killercup commented Jan 28, 2017

Lol, I reinstalled rustfmt an hour ago. Literally! This is my prompt when I scroll up (notice the time on the right):

 ~/P/t/rust-clippy  cargo reinstall rustfmt                                                                                                                                 1.4m  Sat Jan 28 13:14:41 2017

But fine, I'll make you happy, Travis.

@mcarton mcarton merged commit f2f6637 into rust-lang:master Jan 28, 2017
@mcarton
Copy link
Contributor

mcarton commented Jan 28, 2017

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add actual suggestion for explicit_iter_loop

2 participants