]> git.lizzy.rs Git - rust.git/blob - src/test/ui/async-await/issue-61949-self-return-type.rs
Rollup merge of #63509 - estebank:async-span, r=Centril
[rust.git] / src / test / ui / async-await / issue-61949-self-return-type.rs
1 // ignore-tidy-linelength
2 // edition:2018
3 #![feature(async_await)]
4
5 // This test checks that `Self` is prohibited as a return type. See #61949 for context.
6
7 pub struct Foo<'a> {
8     pub bar: &'a i32,
9 }
10
11 impl<'a> Foo<'a> {
12     pub async fn new(_bar: &'a i32) -> Self {
13     //~^ ERROR `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
14         Foo {
15             bar: &22
16         }
17     }
18 }
19
20 async fn foo() {
21     let x = {
22         let bar = 22;
23         Foo::new(&bar).await
24     };
25     drop(x);
26 }
27
28 fn main() { }