-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`F-try_blocks`#![feature(try_blocks)]``#![feature(try_blocks)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
struct A;
struct B;
fn foo() -> Result<A, B> {
Ok(A)
}
fn bar() -> Result<A, B> {
foo()?
}
produces:
error[E0308]: try expression alternatives have incompatible types
--> src/lib.rs:9:5
|
9 | foo()?
| ^^^^^^ expected enum `std::result::Result`, found struct `A`
|
= note: expected type `std::result::Result<A, B>`
found type `A`
It would be helpful if Rust suggested removing the ?
here, as without it, the function has the correct return type.
estebank, florianjacob and zohnannor
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`F-try_blocks`#![feature(try_blocks)]``#![feature(try_blocks)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.