]> git.lizzy.rs Git - rust.git/commitdiff
append more test cases for issue 61076
authorcsmoe <csmoe@msn.com>
Sat, 30 May 2020 14:57:12 +0000 (22:57 +0800)
committercsmoe <csmoe@msn.com>
Tue, 25 Aug 2020 06:00:49 +0000 (14:00 +0800)
src/test/ui/async-await/issue-61076.rs
src/test/ui/async-await/issue-61076.stderr

index 13b45df64eabeae90a487c58341c964c3207a067..e1753b280935db58628c386a65a92d455267210e 100644 (file)
@@ -6,6 +6,16 @@
 
 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() {}
index e71f4e7136dad26f44fef9f604ffe14ec57c30de..af176a734e8097de699e52ef78c472d50b10439b 100644 (file)
@@ -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`.