diff options
| author | csmoe <csmoe@msn.com> | 2020-05-30 22:57:12 +0800 |
|---|---|---|
| committer | csmoe <csmoe@msn.com> | 2020-08-25 14:00:49 +0800 |
| commit | 1d30de6202ea38a204849191cf9723600e522416 (patch) | |
| tree | b7910771c4b4ce0a0efabc365a3568e353d49c29 | |
| parent | ee541284bf5008bb0425fae02412352025099707 (diff) | |
| download | rust-1d30de6202ea38a204849191cf9723600e522416.tar.gz rust-1d30de6202ea38a204849191cf9723600e522416.zip | |
append more test cases for issue 61076
| -rw-r--r-- | src/test/ui/async-await/issue-61076.rs | 22 | ||||
| -rw-r--r-- | src/test/ui/async-await/issue-61076.stderr | 40 |
2 files changed, 58 insertions, 4 deletions
diff --git a/src/test/ui/async-await/issue-61076.rs b/src/test/ui/async-await/issue-61076.rs index 13b45df64ea..e1753b28093 100644 --- a/src/test/ui/async-await/issue-61076.rs +++ b/src/test/ui/async-await/issue-61076.rs @@ -6,6 +6,16 @@ use core::task::{Context, Poll}; struct T; +struct UnionStruct(i32); + +struct Struct { + a: i32 +} + +enum Enum { + A +} + impl Future for T { type Output = Result<(), ()>; @@ -26,7 +36,19 @@ async fn bar() -> Result<(), ()> { async fn baz() -> Result<(), ()> { let t = T; t?; //~ ERROR the `?` operator can only be applied to values that implement `std::ops::Try` + + let _: i32 = async { + UnionStruct(1i32) + }.0; //~ ERROR no field `0` + + let _: i32 = async { + Struct { a: 1i32 } + }.a; //~ ERROR no field `a` + + if let Enum::A = async { Enum::A } {} //~ ERROR mismatched type + Ok(()) } + fn main() {} diff --git a/src/test/ui/async-await/issue-61076.stderr b/src/test/ui/async-await/issue-61076.stderr index e71f4e7136d..af176a734e8 100644 --- a/src/test/ui/async-await/issue-61076.stderr +++ b/src/test/ui/async-await/issue-61076.stderr @@ -1,5 +1,5 @@ error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try` - --> $DIR/issue-61076.rs:22:5 + --> $DIR/issue-61076.rs:32:5 | LL | foo()?; | ^^^^^^ @@ -11,7 +11,7 @@ LL | foo()?; = note: required by `std::ops::Try::into_result` error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try` - --> $DIR/issue-61076.rs:28:5 + --> $DIR/issue-61076.rs:38:5 | LL | t?; | ^^ @@ -22,6 +22,38 @@ LL | t?; = help: the trait `std::ops::Try` is not implemented for `T` = note: required by `std::ops::Try::into_result` -error: aborting due to 2 previous errors +error[E0609]: no field `0` on type `impl std::future::Future` + --> $DIR/issue-61076.rs:42:7 + | +LL | }.0; + | ^ + +error[E0609]: no field `a` on type `impl std::future::Future` + --> $DIR/issue-61076.rs:46:7 + | +LL | }.a; + | ^ + +error[E0308]: mismatched types + --> $DIR/issue-61076.rs:48:12 + | +LL | A + | - unit variant defined here +... +LL | if let Enum::A = async { Enum::A } {} + | ^^^^^^^ ----------- the expected generator + | | + | expected opaque type, found enum `Enum` + | + ::: $SRC_DIR/libcore/future/mod.rs:LL:COL + | +LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return> + | ------------------------------- the expected opaque type + | + = note: expected opaque type `impl std::future::Future` + found enum `Enum` + +error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0308, E0609. +For more information about an error, try `rustc --explain E0277`. |
