Rollup merge of #59859 - davidtwco:issue-59756, r=cramertj
Suggest removing `?` to resolve type errors. Fixes #59756.
This commit is contained in:
commit
2bc127dcc7
8 changed files with 84 additions and 2 deletions
17
src/test/ui/issue-59756.fixed
Normal file
17
src/test/ui/issue-59756.fixed
Normal 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() {}
|
||||
17
src/test/ui/issue-59756.rs
Normal file
17
src/test/ui/issue-59756.rs
Normal 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() {}
|
||||
15
src/test/ui/issue-59756.stderr
Normal file
15
src/test/ui/issue-59756.stderr
Normal 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`.
|
||||
|
|
@ -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`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue