Rollup merge of #59859 - davidtwco:issue-59756, r=cramertj

Suggest removing `?` to resolve type errors.

Fixes #59756.
This commit is contained in:
Mazdak Farrokhzad 2019-04-12 20:36:13 +02:00 committed by GitHub
commit 2bc127dcc7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 84 additions and 2 deletions

View file

@ -0,0 +1,17 @@
// run-rustfix
#![allow(warnings)]
struct A;
struct B;
fn foo() -> Result<A, B> {
Ok(A)
}
fn bar() -> Result<A, B> {
foo()
//~^ ERROR try expression alternatives have incompatible types [E0308]
}
fn main() {}

View file

@ -0,0 +1,17 @@
// run-rustfix
#![allow(warnings)]
struct A;
struct B;
fn foo() -> Result<A, B> {
Ok(A)
}
fn bar() -> Result<A, B> {
foo()?
//~^ ERROR try expression alternatives have incompatible types [E0308]
}
fn main() {}

View file

@ -0,0 +1,15 @@
error[E0308]: try expression alternatives have incompatible types
--> $DIR/issue-59756.rs:13:5
|
LL | foo()?
| ^^^^^-
| | |
| | help: try removing this `?`
| expected enum `std::result::Result`, found struct `A`
|
= note: expected type `std::result::Result<A, B>`
found type `A`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -2,7 +2,10 @@ error[E0308]: try expression alternatives have incompatible types
--> $DIR/issue-51632-try-desugar-incompatible-types.rs:8:5
|
LL | missing_discourses()?
| ^^^^^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found isize
| ^^^^^^^^^^^^^^^^^^^^-
| | |
| | help: try removing this `?`
| expected enum `std::result::Result`, found isize
|
= note: expected type `std::result::Result<isize, ()>`
found type `isize`