-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e7e126b11bc02ef4c8bc28e0d85e0cf0
struct Foo {}
trait IntoBar<'a> {
type Bar: 'static;
}
impl Foo {
async fn stuff<'a, T>(&self, into_bar: T) -> T::Bar
where
T: IntoBar<'a>,
{
todo!();
}
}
I expected to see the code compile.
Instead, this happened:
error[[E0658]](https://doc.rust-lang.org/stable/error_codes/E0658.html): `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
--> src/lib.rs:8:50
|
8 | async fn stuff<'a, T>(&self, into_bar: T) -> T::Bar
| ^^^^^^
|
= note: [see issue #103532 <https://github.com/rust-lang/rust/issues/103532>](https://github.com/rust-lang/rust/issues/103532) for more information
For more information about this error, try `rustc --explain E0658`.
Fails on nightly (apr 10), beta (1.69), stable (1.68).
Curiously, this code doesn't fail:
struct Foo {}
trait IntoBar<'a> {
type Bar: 'static;
}
impl Foo {
async fn stuff<'a, T>(&self, into_bar: T) -> <T as IntoBar<'a>>::Bar
where
T: IntoBar<'a>,
{
todo!();
}
}
... nor does changing the return type to <T as IntoBar<'_>>::Bar
...
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Status
Done