Fix false positive of useless_conversion when using .into_iter().any() (#14800)
Fixes: rust-lang/rust-clippy#14656 changelog: Fix [`useless_conversion`] false positive when using `.into_iter().any()`.
This commit is contained in:
commit
ff5e626837
4 changed files with 71 additions and 2 deletions
|
|
@ -427,3 +427,18 @@ mod issue11819 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn issue14739() {
|
||||
use std::ops::Range;
|
||||
|
||||
const R: Range<u32> = 2..7;
|
||||
|
||||
R.into_iter().all(|_x| true); // no lint
|
||||
|
||||
R.into_iter().any(|_x| true); // no lint
|
||||
|
||||
R.for_each(|_x| {});
|
||||
//~^ useless_conversion
|
||||
let _ = R.map(|_x| 0);
|
||||
//~^ useless_conversion
|
||||
}
|
||||
|
|
|
|||
|
|
@ -427,3 +427,18 @@ mod issue11819 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn issue14739() {
|
||||
use std::ops::Range;
|
||||
|
||||
const R: Range<u32> = 2..7;
|
||||
|
||||
R.into_iter().all(|_x| true); // no lint
|
||||
|
||||
R.into_iter().any(|_x| true); // no lint
|
||||
|
||||
R.into_iter().for_each(|_x| {});
|
||||
//~^ useless_conversion
|
||||
let _ = R.into_iter().map(|_x| 0);
|
||||
//~^ useless_conversion
|
||||
}
|
||||
|
|
|
|||
|
|
@ -377,5 +377,17 @@ LL - takes_into_iter(self.my_field.into_iter());
|
|||
LL + takes_into_iter(&mut *self.my_field);
|
||||
|
|
||||
|
||||
error: aborting due to 41 previous errors
|
||||
error: useless conversion to the same type: `std::ops::Range<u32>`
|
||||
--> tests/ui/useless_conversion.rs:440:5
|
||||
|
|
||||
LL | R.into_iter().for_each(|_x| {});
|
||||
| ^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `R`
|
||||
|
||||
error: useless conversion to the same type: `std::ops::Range<u32>`
|
||||
--> tests/ui/useless_conversion.rs:442:13
|
||||
|
|
||||
LL | let _ = R.into_iter().map(|_x| 0);
|
||||
| ^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `R`
|
||||
|
||||
error: aborting due to 43 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue