Closed
Description
use std::collections::HashMap;
fn main() {
for _ in HashMap::new().iter().cloned() { }
}
.cloned()
failing is normal since the iterator's items are (&K, &V)
and .cloned()
expects &T
, but the number of errors is strange.
error: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as std::iter::Iterator>::Item == &_`:
expected tuple,
found &-ptr [--explain E0271]
--> <anon>:4:36
4 |> for _ in HashMap::new().iter().cloned() { }
|> ^^^^^^
error: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as std::iter::Iterator>::Item == &_`:
expected tuple,
found &-ptr [--explain E0271]
--> <anon>:4:5
4 |> for _ in HashMap::new().iter().cloned() { }
|> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required because of the requirements on the impl of `std::iter::Iterator` for `std::iter::Cloned<std::collections::hash_map::Iter<'_, _, _>>`
error: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as std::iter::Iterator>::Item == &_`:
expected tuple,
found &-ptr [--explain E0271]
--> <anon>:4:5
4 |> for _ in HashMap::new().iter().cloned() { }
|> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required because of the requirements on the impl of `std::iter::Iterator` for `std::iter::Cloned<std::collections::hash_map::Iter<'_, _, _>>`
error: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as std::iter::Iterator>::Item == &_`:
expected tuple,
found &-ptr [--explain E0271]
--> <anon>:4:5
4 |> for _ in HashMap::new().iter().cloned() { }
|> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required because of the requirements on the impl of `std::iter::Iterator` for `std::iter::Cloned<std::collections::hash_map::Iter<'_, _, _>>`
note: required by `std::iter::IntoIterator::into_iter`
error: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as std::iter::Iterator>::Item == &_`:
expected tuple,
found &-ptr [--explain E0271]
--> <anon>:4:5
4 |> for _ in HashMap::new().iter().cloned() { }
|> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required because of the requirements on the impl of `std::iter::Iterator` for `std::iter::Cloned<std::collections::hash_map::Iter<'_, _, _>>`
note: required by `std::iter::IntoIterator::into_iter`
error: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as std::iter::Iterator>::Item == &_`:
expected tuple,
found &-ptr [--explain E0271]
--> <anon>:4:5
4 |> for _ in HashMap::new().iter().cloned() { }
|> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required because of the requirements on the impl of `std::iter::Iterator` for `std::iter::Cloned<std::collections::hash_map::Iter<'_, _, _>>`
note: required because of the requirements on the impl of `std::iter::IntoIterator` for `std::iter::Cloned<std::collections::hash_map::Iter<'_, _, _>>`
error: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as std::iter::Iterator>::Item == &_`:
expected tuple,
found &-ptr [--explain E0271]
--> <anon>:4:5
4 |> for _ in HashMap::new().iter().cloned() { }
|> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required because of the requirements on the impl of `std::iter::Iterator` for `std::iter::Cloned<std::collections::hash_map::Iter<'_, _, _>>`
error: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as std::iter::Iterator>::Item == &_`:
expected tuple,
found &-ptr [--explain E0271]
--> <anon>:4:5
4 |> for _ in HashMap::new().iter().cloned() { }
|> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required because of the requirements on the impl of `std::iter::Iterator` for `std::iter::Cloned<std::collections::hash_map::Iter<'_, _, _>>`
note: required by `std::iter::Iterator::next`
error: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as std::iter::Iterator>::Item == &_`:
expected tuple,
found &-ptr [--explain E0271]
--> <anon>:4:5
4 |> for _ in HashMap::new().iter().cloned() { }
|> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required because of the requirements on the impl of `std::iter::Iterator` for `std::iter::Cloned<std::collections::hash_map::Iter<'_, _, _>>`
error: aborting due to 9 previous errors
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsCategory: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint that should be reworked.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.Working group: Diagnostics