Skip to content

Commit ee691e0

Browse files
committed
add test for #102605
1 parent d9f8b4b commit ee691e0

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// edition:2021
2+
3+
async fn foo() -> Result<(), String> {
4+
Ok(())
5+
}
6+
7+
fn convert_result<T, E>(r: Result<T, E>) -> Option<T> {
8+
None
9+
}
10+
11+
fn main() -> Option<()> {
12+
//~^ ERROR `main` has invalid return type `Option<()>`
13+
convert_result(foo())
14+
//~^ ERROR mismatched types
15+
}
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-102605.rs:13:20
3+
|
4+
LL | convert_result(foo())
5+
| -------------- ^^^^^ expected enum `Result`, found opaque type
6+
| |
7+
| arguments to this function are incorrect
8+
|
9+
note: while checking the return type of the `async fn`
10+
--> $DIR/issue-102605.rs:3:19
11+
|
12+
LL | async fn foo() -> Result<(), String> {
13+
| ^^^^^^^^^^^^^^^^^^ checked the `Output` of this `async fn`, found opaque type
14+
= note: expected enum `Result<(), _>`
15+
found opaque type `impl Future<Output = Result<(), String>>`
16+
note: function defined here
17+
--> $DIR/issue-102605.rs:7:4
18+
|
19+
LL | fn convert_result<T, E>(r: Result<T, E>) -> Option<T> {
20+
| ^^^^^^^^^^^^^^ ---------------
21+
help: consider `await`ing on the `Future`
22+
|
23+
LL | convert_result(foo().await)
24+
| ++++++
25+
help: try wrapping the expression in `Err`
26+
|
27+
LL | convert_result(Err(foo()))
28+
| ++++ +
29+
30+
error[E0277]: `main` has invalid return type `Option<()>`
31+
--> $DIR/issue-102605.rs:11:14
32+
|
33+
LL | fn main() -> Option<()> {
34+
| ^^^^^^^^^^ `main` can only return types that implement `Termination`
35+
|
36+
= help: consider using `()`, or a `Result`
37+
38+
error: aborting due to 2 previous errors
39+
40+
Some errors have detailed explanations: E0277, E0308.
41+
For more information about an error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)