Closed
Description
When returning Result<_, A>
but Result<_, B>
is expected and A: Into<B>
, provide a suggestion to return Ok(x?)
instead:
error[E0308]: mismatched types
--> src/bin/ruby-stacktrace.rs:86:20
|
86 | return version;
| ^^^^^^^ expected struct `failure::Error`, found enum `ruby_stacktrace::address_finder::AddressFinderError`
|
= note: expected type `std::result::Result<_, failure::Error>`
found type `std::result::Result<_, ruby_stacktrace::address_finder::AddressFinderError>`
= help: because `ruby_stacktrace::address_finder::AddressFinderError` implements `failure::Error`, you can use `?` to coerce it:
|
86 | return Ok(version?);
| ^^^^^^^^^^^^
Case taken from https://jvns.ca/blog/2018/01/13/rust-in-2018--way-easier-to-use/
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; hard to understand for new users.Relevant to the compiler team, which will review and decide on the PR/issue.