summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_error_codes/src/error_codes/E0760.md
blob: e1dcfefebcd762187aba9a1d49a0b44154696787 (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
29
30
31
32
`async fn`/`impl trait` return type cannot contain a projection
or `Self` that references lifetimes from a parent scope.

Erroneous code example:

```compile_fail,E0760,edition2018
struct S<'a>(&'a i32);

impl<'a> S<'a> {
    async fn new(i: &'a i32) -> Self {
        S(&22)
    }
}
```

To fix this error we need to spell out `Self` to `S<'a>`:

```edition2018
struct S<'a>(&'a i32);

impl<'a> S<'a> {
    async fn new(i: &'a i32) -> S<'a> {
        S(&22)
    }
}
```

This will be allowed at some point in the future,
but the implementation is not yet complete.
See the [issue-61949] for this limitation.

[issue-61949]: https://github.com/rust-lang/rust/issues/61949