-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Description
I tried this code:
fn f2() {
let mut a = 5u64;
let mut b = 3u64;
let items = vec![&mut a, &mut b];
let items2 = items.into_iter().map(|i| i.clone()).collect::<Vec<u64>>();
}
fn main() {
}
I expected to see this happen: a doable suggestion.
Instead, this happened: the suggestion isn't possible to satisfy: the cloned()
method on an iterator of mutable references can't produce a collection of cloned/owned objects:
fn f2() {
let mut a = 5u64;
let mut b = 3u64;
let items = vec![&mut a, &mut b];
let items2 = items.into_iter().cloned().collect::<Vec<u64>>();
}
fn main() {
}
Because:
error[E0271]: type mismatch resolving `<std::vec::IntoIter<&mut u64> as std::iter::Iterator>::Item == &_`
--> src/main.rs:5:36
|
5 | let items2 = items.into_iter().cloned().collect::<Vec<u64>>();
| ^^^^^^ types differ in mutability
|
= note: expected type `&mut u64`
found reference `&_`
Meta
cargo clippy -V
: clippy 0.0.212 (18bf6b4 2020-10-07)rustc -Vv
:
rustc 1.47.0 (18bf6b4f0 2020-10-07)
binary: rustc
commit-hash: 18bf6b4f01a6feaf7259ba7cdae58031af1b7b39
commit-date: 2020-10-07
host: x86_64-unknown-linux-gnu
release: 1.47.0
LLVM version: 11.0
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied