-
Notifications
You must be signed in to change notification settings - Fork 13.3k
nightly-only types are confusing in error[E0277]: ?
couldn't convert the error to ...
#121521
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
I should also note that the "terminal" representation of this error isn't that bad, but in rust-analyzer (in vscode anyway) it's a lot more confusing, because it mashes all the text together, making it harder to identify the useful part. |
This commit starts using `#[diagnostic::do_not_recommend]` in the standard library to improve some error messages. In this case we just hide a certain nightly only impl as suggested in rust-lang#121521
This commit starts using `#[diagnostic::do_not_recommend]` in the standard library to improve some error messages. In this case we just hide a certain nightly only impl as suggested in rust-lang#121521
Start using `#[diagnostic::do_not_recommend]` in the standard library This commit starts using `#[diagnostic::do_not_recommend]` in the standard library to improve some error messages. In this case we just hide a certain nightly only impl as suggested in rust-lang#121521 The result in not perfect yet, but at least the `Yeet` suggestion is not shown anymore. I would consider that as a minor improvement.
Rollup merge of rust-lang#128008 - weiznich:fix/121521, r=lcnr Start using `#[diagnostic::do_not_recommend]` in the standard library This commit starts using `#[diagnostic::do_not_recommend]` in the standard library to improve some error messages. In this case we just hide a certain nightly only impl as suggested in rust-lang#121521 The result in not perfect yet, but at least the `Yeet` suggestion is not shown anymore. I would consider that as a minor improvement.
Using this version:
The error is now this:
Which is not so confusing, I think. So can this issue be closed? |
I agree, it's better than it was before. But I think we can do better. The It's also unhelpful that two lines of the error message go on about ``FromResidual<Result<Infallible, _>>` which is completely irrelevant to this code. This must be one of the most common beginner errors, so it seems like a good place to be as clear and helpful as we can. |
Agreed, what we really need (I think) is a message that "de-sugars" the ? to its equivalent match expression, which makes the error much plainer, so something like:
Note if I replace bar()? with match (as above) in the sample code the error becomes:
Which does nicely explain the problem and gives one way to solve it (implement From for FooError). |
Code
Current output
Desired output
I'm not sure.
Rationale and extra context
This is a very common error, and it's likely to be encountered by people new to Rust.
The
note
andhelp
text mentions two different types that are nightly-only (Yeet
,FromResidual
). To someone who is learning the language or only using the stable compiler, this is both confusing and unhelpful.I think the stable compiler should avoid mentioning internal or nightly-only types, and when possible, the advice given should be understandable and actionable by someone new to the language.
If the last two messages are only going to talk about nightly only types, and they're not actually helpful to someone using the stable compiler, maybe they should just be removed?
Other cases
No response
Rust Version
Anything else?
I filed this bug after a conversation with @estebank on mastodon. 👋
The text was updated successfully, but these errors were encountered: