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