]>
git.proxmox.com Git - rustc.git/blob - tests/ui/async-await/issue-61076.rs
3 use core
::future
::Future
;
5 use core
::task
::{Context, Poll}
;
19 impl Future
for Struct
{
21 fn poll(self: Pin
<&mut Self>, _
: &mut Context
<'_
>) -> Poll
<Self::Output
> { Poll::Pending }
24 impl Future
for Tuple
{
26 fn poll(self: Pin
<&mut Self>, _
: &mut Context
<'_
>) -> Poll
<Self::Output
> { Poll::Pending }
30 type Output
= Result
<(), ()>;
32 fn poll(self: Pin
<&mut Self>, _
: &mut Context
<'_
>) -> Poll
<Self::Output
> {
37 async
fn foo() -> Result
<(), ()> {
41 async
fn bar() -> Result
<(), ()> {
42 foo()?
; //~ ERROR the `?` operator can only be applied to values that implement `Try`
43 //~^ NOTE the `?` operator cannot be applied to type `impl Future<Output = Result<(), ()>>`
44 //~| HELP the trait `Try` is not implemented for `impl Future<Output = Result<(), ()>>`
45 //~| HELP consider `await`ing on the `Future`
46 //~| NOTE in this expansion of desugaring of operator `?`
47 //~| NOTE in this expansion of desugaring of operator `?`
48 //~| NOTE in this expansion of desugaring of operator `?`
52 async
fn struct_() -> Struct
{
56 async
fn tuple() -> Tuple
{
60 async
fn baz() -> Result
<(), ()> {
62 t?
; //~ ERROR the `?` operator can only be applied to values that implement `Try`
63 //~^ NOTE the `?` operator cannot be applied to type `T`
64 //~| HELP the trait `Try` is not implemented for `T`
65 //~| HELP consider `await`ing on the `Future`
66 //~| NOTE in this expansion of desugaring of operator `?`
67 //~| NOTE in this expansion of desugaring of operator `?`
68 //~| NOTE in this expansion of desugaring of operator `?`
71 let _
: i32 = tuple().0; //~ ERROR no field `0`
72 //~^ HELP consider `await`ing on the `Future`
73 //~| NOTE field not available in `impl Future`
75 let _
: i32 = struct_().a
; //~ ERROR no field `a`
76 //~^ HELP consider `await`ing on the `Future`
77 //~| NOTE field not available in `impl Future`
79 struct_().method(); //~ ERROR no method named
80 //~^ NOTE method not found in `impl Future<Output = Struct>`
81 //~| HELP consider `await`ing on the `Future`
86 match tuple() { //~ HELP consider `await`ing on the `Future`
87 //~^ NOTE this expression has type `impl Future<Output = Tuple>`
88 Tuple(_
) => {}
//~ ERROR mismatched types
89 //~^ NOTE expected future, found `Tuple`
90 //~| NOTE expected opaque type `impl Future<Output = Tuple>`