Skip to content

Commit 1d30de6

Browse files
committed
append more test cases for issue 61076
1 parent ee54128 commit 1d30de6

File tree

2 files changed

+58
-4
lines changed

2 files changed

+58
-4
lines changed

src/test/ui/async-await/issue-61076.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ use core::task::{Context, Poll};
66

77
struct T;
88

9+
struct UnionStruct(i32);
10+
11+
struct Struct {
12+
a: i32
13+
}
14+
15+
enum Enum {
16+
A
17+
}
18+
919
impl Future for T {
1020
type Output = Result<(), ()>;
1121

@@ -26,7 +36,19 @@ async fn bar() -> Result<(), ()> {
2636
async fn baz() -> Result<(), ()> {
2737
let t = T;
2838
t?; //~ ERROR the `?` operator can only be applied to values that implement `std::ops::Try`
39+
40+
let _: i32 = async {
41+
UnionStruct(1i32)
42+
}.0; //~ ERROR no field `0`
43+
44+
let _: i32 = async {
45+
Struct { a: 1i32 }
46+
}.a; //~ ERROR no field `a`
47+
48+
if let Enum::A = async { Enum::A } {} //~ ERROR mismatched type
49+
2950
Ok(())
3051
}
3152

53+
3254
fn main() {}

src/test/ui/async-await/issue-61076.stderr

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
2-
--> $DIR/issue-61076.rs:22:5
2+
--> $DIR/issue-61076.rs:32:5
33
|
44
LL | foo()?;
55
| ^^^^^^
@@ -11,7 +11,7 @@ LL | foo()?;
1111
= note: required by `std::ops::Try::into_result`
1212

1313
error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
14-
--> $DIR/issue-61076.rs:28:5
14+
--> $DIR/issue-61076.rs:38:5
1515
|
1616
LL | t?;
1717
| ^^
@@ -22,6 +22,38 @@ LL | t?;
2222
= help: the trait `std::ops::Try` is not implemented for `T`
2323
= note: required by `std::ops::Try::into_result`
2424

25-
error: aborting due to 2 previous errors
25+
error[E0609]: no field `0` on type `impl std::future::Future`
26+
--> $DIR/issue-61076.rs:42:7
27+
|
28+
LL | }.0;
29+
| ^
30+
31+
error[E0609]: no field `a` on type `impl std::future::Future`
32+
--> $DIR/issue-61076.rs:46:7
33+
|
34+
LL | }.a;
35+
| ^
36+
37+
error[E0308]: mismatched types
38+
--> $DIR/issue-61076.rs:48:12
39+
|
40+
LL | A
41+
| - unit variant defined here
42+
...
43+
LL | if let Enum::A = async { Enum::A } {}
44+
| ^^^^^^^ ----------- the expected generator
45+
| |
46+
| expected opaque type, found enum `Enum`
47+
|
48+
::: $SRC_DIR/libcore/future/mod.rs:LL:COL
49+
|
50+
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
51+
| ------------------------------- the expected opaque type
52+
|
53+
= note: expected opaque type `impl std::future::Future`
54+
found enum `Enum`
55+
56+
error: aborting due to 5 previous errors
2657

27-
For more information about this error, try `rustc --explain E0277`.
58+
Some errors have detailed explanations: E0277, E0308, E0609.
59+
For more information about an error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)