-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #72260 - csmoe:issue-69276, r=estebank
- Loading branch information
Showing
5 changed files
with
97 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
error: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope | ||
error[E0760]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope | ||
--> $DIR/issue-61949-self-return-type.rs:11:40 | ||
| | ||
LL | pub async fn new(_bar: &'a i32) -> Self { | ||
| ^^^^ | ||
| ^^^^ help: consider spelling out the type instead: `Foo<'a>` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0760`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters