Closed
Description
It seems that rustc
should provide a better error message or hint when one tries to use the ?
operator on an Option
in a function returning a Result
or vice-versa.
Currently this is the error you get:
error[E0277]: `?` couldn't convert the error to `MyErrorType`
--> src/main.rs:10:19
|
10 | let a = foo(i)?;
| ^ the trait `std::convert::From<std::option::NoneError>` is not implemented for `MyErrorType`
|
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
= note: required by `std::convert::From::from`
However, it would be better to suggest the use of Option::ok_or
or Option::ok_or_else
, or Result::ok
, instead of referencing something dependent on the try_trait
feature (NoneError
).
This issue has been assigned to @Duddino via this comment.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsCategory: An issue proposing an enhancement or a PR with one.Diagnostics: An error or lint that needs small tweaks.Error messages that can be tackled with `#[rustc_on_unimplemented]`Relevant to the compiler team, which will review and decide on the PR/issue.