Closed
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.