]> git.proxmox.com Git - rustc.git/blob - tests/ui/async-await/issue-61949-self-return-type.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / async-await / issue-61949-self-return-type.rs
1 // edition:2018
2 // gate-test-impl_trait_projections
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 //~^ ERROR `bar` does not live long enough
24 };
25 drop(x);
26 }
27
28 fn main() { }