-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error for for _ in HashMap::new().iter().cloned() { }
doesn't provide enough context
#33941
Comments
I also think the error should be improved. |
Current output:
There are two problems here that can be tackled independently:
In general, it would probably be nice to have something along the lines of the following output on cases where type errors are propagated down a method call chain, but it's non-trivial to do and would still add little help here, so it should be out of scope of this issue:
|
The `ErrorId` variant takes a u16 so that `DiagnosticMessageId` can retain its `Copy` status (the present author's first choice having been the "EXXX" code as a string). The duplicated "type mismatch resolving `{}`" literal is unfortunate, but the `struct_span_err!` macro (which we want to mark that error code as used) is fussy about taking a literal, and the one-time-diagnostics set needs an owned string. This is concerning rust-lang#33941 and probably rust-lang#45805!
…stebank deduplicate projection error (E0271) messages The `ErrorId` variant takes a u16 so that `DiagnosticMessageId` can retain its `Copy` status (the present author's first choice having been the "EXXX" code as a string). The duplicated "type mismatch resolving `{}`" literal is unfortunate, but the `struct_span_err!` macro (which we want to mark that error code as used) is fussy about taking a literal, and the one-time-diagnostics set needs an owned string. This is concerning rust-lang#33941 and probably rust-lang#45805! r? @estebank
for _ in HashMap::new().iter().cloned() { }
produces 9 (near-)duplicate errorsfor _ in HashMap::new().iter().cloned() { }
doesn't provide enough context
Triage: no change. |
I wonder is there handy utils to convert |
``` error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as Iterator>::Item == &_` --> $DIR/issue-33941.rs:6:36 | LL | for _ in HashMap::new().iter().cloned() {} | ------------ ---- ^^^^^^ expected reference, found tuple | | | | | this call is of type `std::collections::hash_map::Iter<'_, _, _>` | this call is of type `&HashMap<_, _>` | = note: expected reference `&_` found tuple `(&_, &_)` note: required by a bound in `cloned` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | LL | Self: Sized + Iterator<Item = &'a T>, | ^^^^^^^^^^^^ required by this bound in `cloned` ``` Partially address rust-lang#33941.
Point at method chains on `E0271` errors Follow up to rust-lang#105332. Fix rust-lang#33941. CC rust-lang#9082. r? `@oli-obk`
Point at method chains on `E0271` errors Follow up to rust-lang#105332. Fix rust-lang#33941. CC rust-lang#9082. r? ``@oli-obk``
Point at method chains on `E0271` errors Follow up to rust-lang#105332. Fix rust-lang#33941. CC rust-lang#9082. r? ```@oli-obk```
Playpen
.cloned()
failing is normal since the iterator's items are(&K, &V)
and.cloned()
expects&T
, but the number of errors is strange.The text was updated successfully, but these errors were encountered: