1
Fork 0
rust/src/test/ui/async-await/issue-61076.rs

55 lines
961 B
Rust
Raw Normal View History

2020-05-06 18:43:56 +08:00
// edition:2018
2020-05-14 23:07:46 +08:00
use core::future::Future;
use core::pin::Pin;
use core::task::{Context, Poll};
struct T;
2020-05-30 22:57:12 +08:00
struct UnionStruct(i32);
struct Struct {
a: i32
}
enum Enum {
A
}
2020-05-14 23:07:46 +08:00
impl Future for T {
type Output = Result<(), ()>;
fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
Poll::Pending
}
}
2020-05-06 18:43:56 +08:00
async fn foo() -> Result<(), ()> {
Ok(())
}
async fn bar() -> Result<(), ()> {
2020-05-10 22:34:20 +08:00
foo()?; //~ ERROR the `?` operator can only be applied to values that implement `std::ops::Try`
2020-05-06 18:43:56 +08:00
Ok(())
}
2020-05-14 23:07:46 +08:00
async fn baz() -> Result<(), ()> {
let t = T;
t?; //~ ERROR the `?` operator can only be applied to values that implement `std::ops::Try`
2020-05-30 22:57:12 +08:00
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
2020-05-14 23:07:46 +08:00
Ok(())
}
2020-05-30 22:57:12 +08:00
2020-05-06 18:43:56 +08:00
fn main() {}