Closed
Description
Summary
clippy version: clippy 0.1.87 (e2014e8 2025-04-01)
Invalid Turbofish of .collect()
?
Reproducer
I tried this code:
#[warn(clippy::from_iter_instead_of_collect)]
fn main() {
let nums = [0, 1, 2];
let _ = &String::from_iter(
nums.iter().map(|&num| char::from_u32(num).unwrap()),
);
}
I expected to see this happen:
warning: usage of `FromIterator::from_iter`
--> src/main.rs:4:14
|
4 | let _ = &String::from_iter(
| ______________^
5 | | nums.iter().map(|&num| char::from_u32(num).unwrap()),
6 | | );
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#from_iter_instead_of_collect
note: the lint level is defined here
--> src/main.rs:1:8
|
1 | #[warn(clippy::from_iter_instead_of_collect)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: use `.collect()` instead of `::from_iter()`
|
4 ~ let _ = &nums.iter().map(|&num| char::from_u32(num).unwrap()).collect::<String>();
|
warning: `test_` (bin "test_") generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.06s
Instead, this happened:
warning: usage of `FromIterator::from_iter`
--> src/main.rs:4:14
|
4 | let _ = &String::from_iter(
| ______________^
5 | | nums.iter().map(|&num| char::from_u32(num).unwrap()),
6 | | );
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#from_iter_instead_of_collect
note: the lint level is defined here
--> src/main.rs:1:8
|
1 | #[warn(clippy::from_iter_instead_of_collect)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: use `.collect()` instead of `::from_iter()`
|
4 ~ let _ = &nums.iter().map(|&num| char::from_u32(num).unwrap()).collect::<String::from_iter(
5 ~ nums.iter().map(|&num| char<_>>();
|
warning: `test_` (bin "test_") generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.06s
Version
rustc 1.88.0-nightly (e2014e876 2025-04-01)
binary: rustc
commit-hash: e2014e876e3efaa69bf51c19579adb16c3df5f81
commit-date: 2025-04-01
host: aarch64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.1
Additional Labels
No response