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