Skip to content

Commit 008d90a

Browse files
committed
create error code E0754
1 parent 29a41f0 commit 008d90a

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/librustc_error_codes/error_codes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ E0750: include_str!("./error_codes/E0750.md"),
435435
E0751: include_str!("./error_codes/E0751.md"),
436436
E0752: include_str!("./error_codes/E0752.md"),
437437
E0753: include_str!("./error_codes/E0753.md"),
438+
E0754: include_str!("./error_codes/E0754.md"),
438439
;
439440
// E0006, // merged with E0005
440441
// E0008, // cannot bind by-move into a pattern guard
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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

0 commit comments

Comments
 (0)