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