-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
better error message when ?
is applied to collect()
#49391
Comments
I think that the way to fix this is -- first and foremost -- to remove E0284, which is basically the same as E0282 but with "less good" error reporting. To do that, we want to redirect this code: rust/src/librustc/traits/error_reporting.rs Lines 1264 to 1273 in 097efa9
so that it invokes the
as it happens, other code from trait error reporting file already invokes rust/src/librustc/traits/error_reporting.rs Lines 1243 to 1249 in 097efa9
so I think we just need to change this hunk to work the same way. |
That said, my guess is that this won't fix the original example. To do that, we have to extend |
@nikomatsakis, Following from IRC, I'll pick this one up and begin working on this. Thank you for the helpful tips. :-) |
It's been a while now; @balajisivaraman, are you still interested in this issue? Otherwise I'd like to pick it up. |
@ytausky, Unfortunately, I've not made much progress on this. (I'm still slowly working my way through the Rustc Guide.) You can pick it up if you'd like. |
@ytausky are you still interested in this issue? If not, I would like to pick it up. |
Sure, life got in between, I'm not working on this. |
Hey guys I can help to look into this if no one picks this up yet. |
@ytausky I would like to give this a shot. I'm new to rust. |
Going to proactively close, Niko can reopen if needed. |
The case still repros, I was checking the wrong code. |
Output with #65951:
|
Don't know if the compiler can be a bit more smarter about the error message on this case, but I stumbled upon here when I wrote (with
Giving the strange:
|
@hwalinga could you file a new ticket with a link to a reproduction care on the playground? A quick attempt at reproducing the StackOverflow case yielded a "type annotations needed" error and following the suggestions for it leads you in the right direction, but I might be sinning of being overly familiar with what the compiler is trying to say. |
This code:
gives a terrible error:
The solution is to do
.collect::<Result<Vec<_>,_>>()?
(playground)The text was updated successfully, but these errors were encountered: