struct T;
+struct UnionStruct(i32);
+
+struct Struct {
+ a: i32
+}
+
+enum Enum {
+ A
+}
+
impl Future for T {
type Output = 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() {}
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()?;
| ^^^^^^
= 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?;
| ^^
= 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`.