summaryrefslogtreecommitdiffstats
path: root/src/test/ui/async-await/feature-self-return-type.rs
blob: 41f887430c1cb8bcf7e3bdd3d9205d28c997db97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// edition:2018
#![feature(impl_trait_projections)]

// This test checks that we emit the correct borrowck error when `Self` is used as a return type.
// See #61949 for context.

pub struct Foo<'a> {
    pub bar: &'a i32,
}

impl<'a> Foo<'a> {
    pub async fn new(_bar: &'a i32) -> Self {
        Foo {
            bar: &22
        }
    }
}

pub async fn foo() {
    let x = {
        let bar = 22;
        Foo::new(&bar).await
        //~^ ERROR `bar` does not live long enough
    };
    drop(x);
}

fn main() { }