-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Diagnostics for trait methods with additional unmet bounds can be confusing to read #100433
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
Comments
This is a known issue, I remember @compiler-errors have finished the PR, seems the doc haven't been updated. |
@chenyukang this issue is somewhat orthogonal. #100176 is about displaying the rustdocs for This is about the error message that comes from calling |
@semicoleon I'm not exactly sure if I understand the changes you want to see here. The use std::collections::HashMap;
fn map() {
let map = HashMap::<u32, u32>::new();
let _ = map.iter().rev();
} Then we get the very similar error message:
I can investigate why this error message is (almost) duplicated though. |
Oh I guess this part is what you're asking for:
Yeah, let me see if I can specialize the error message specifically for |
That is likely due to the
That would be good. For the case in particular of |
I updated the original issue to hopefully be more clear about what I was talking about, sorry for the confusion! |
A URLO thread about confusion over why
Iterator
'srev
method didn't work forHashMap
's iterators kicked off some discussion about the way the error message was phrased.It has all of the information about the root cause of the error (a missing impl), as well as what caused that requirement to be introduced (calling
rev
). I think the ordering of the information is a little confusing though, especially for people new to the language.Given the following code:
Playground
The current output is:
I think it might be worth starting with a message about what the user did to cause the error rather than the root cause.
Mostly unrelated
As I was writing this up I also noticed that the last error "required because of the requirements on the impl of `IntoIterator`" doesn't explain why `IntoIterator` is involved. It might be worth tacking on a note that for loops call into_iter automatically to clarify why that's there.Ideally the output should look like:
The text was updated successfully, but these errors were encountered: