Closed
Description
The following code produces an unexpected error message:
test.split_whitespace().next().ok_or_else(|| {
format_err!("Couldn't split the test string");
})?;
I expected the compiler to give me a warning like "ok_or_else
needs to return the trait std::error::Error
. Instead you are returning ()
. Suggestion: remove the ;
.
Instead, I received the following error message which was hard to parse:
| })?;
| ^ the trait `std::error::Error` is not implemented for `()`
|
= note: required because of the requirements on the impl of `failure::Fail` for `()`
= note: required because of the requirements on the impl of `std::convert::From<()>` for `failure::Error`
= note: required by `std::convert::From::from`
The rust compiler version that I am using is 1.43.1
. This behavior also exists within the beta and nightly versions. I also created an example using the rust-playground here: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=33e42842b0d6385ea5704e323c113e7f.
Thanks again!
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Category: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint that should be reworked.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.