]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0760.md
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0760.md
1 `async fn`/`impl trait` return type cannot contain a projection
2 or `Self` that references lifetimes from a parent scope.
3
4 Erroneous code example:
5
6 ```compile_fail,E0760,edition2018
7 struct S<'a>(&'a i32);
8
9 impl<'a> S<'a> {
10     async fn new(i: &'a i32) -> Self {
11         S(&22)
12     }
13 }
14 ```
15
16 To fix this error we need to spell out `Self` to `S<'a>`:
17
18 ```edition2018
19 struct S<'a>(&'a i32);
20
21 impl<'a> S<'a> {
22     async fn new(i: &'a i32) -> S<'a> {
23         S(&22)
24     }
25 }
26 ```
27
28 This will be allowed at some point in the future,
29 but the implementation is not yet complete.
30 See the [issue-61949] for this limitation.
31
32 [issue-61949]: https://github.com/rust-lang/rust/issues/61949