create error code E0754
This commit is contained in:
parent
29a41f0d86
commit
008d90a66a
2 changed files with 30 additions and 0 deletions
|
|
@ -435,6 +435,7 @@ E0750: include_str!("./error_codes/E0750.md"),
|
|||
E0751: include_str!("./error_codes/E0751.md"),
|
||||
E0752: include_str!("./error_codes/E0752.md"),
|
||||
E0753: include_str!("./error_codes/E0753.md"),
|
||||
E0754: include_str!("./error_codes/E0754.md"),
|
||||
;
|
||||
// E0006, // merged with E0005
|
||||
// E0008, // cannot bind by-move into a pattern guard
|
||||
|
|
|
|||
29
src/librustc_error_codes/error_codes/E0754.md
Normal file
29
src/librustc_error_codes/error_codes/E0754.md
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
`async fn`/`impl trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0754,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
|
||||
Loading…
Add table
Add a link
Reference in a new issue