]> git.lizzy.rs Git - rust.git/blob - tests/ui/async-await/feature-self-return-type.rs
Rollup merge of #106944 - Nilstrieb:there-once-was-a-diagnostic, r=WaffleLapkin
[rust.git] / tests / ui / async-await / feature-self-return-type.rs
1 // edition:2018
2 #![feature(impl_trait_projections)]
3
4 // This test checks that we emit the correct borrowck error when `Self` is used as a return type.
5 // 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         Foo {
14             bar: &22
15         }
16     }
17 }
18
19 pub async fn foo() {
20     let x = {
21         let bar = 22;
22         Foo::new(&bar).await
23         //~^ ERROR `bar` does not live long enough
24     };
25     drop(x);
26 }
27
28 fn main() { }