Closed
Description
Tracking issue: #91611
A few months ago I authored a complete example for a possible AsyncIterator::lend
method. This used to compile fine on rustc 1.71.0-nightly (f5559e338 2023-04-24)
, but it no longer does on the latest nightly. Here is a minimized repro:
#![allow(incomplete_features)]
#![feature(async_fn_in_trait)]
trait AsyncLendingIterator {
type Item<'a>
where
Self: 'a;
async fn next(&mut self) -> Option<Self::Item<'_>>;
}
struct Lend<I>(I);
impl<I> AsyncLendingIterator for Lend<I> {
type Item<'a> = &'a I
where
Self: 'a;
async fn next(&mut self) -> Option<Self::Item<'_>> {
todo!()
}
}
This gives the following error:
Compiling playground v0.0.1 (/playground)
error[[E0311]](https://doc.rust-lang.org/nightly/error_codes/E0311.html): the parameter type `T` may not live long enough
--> src/main.rs:29:5
|
29 | async fn next(&mut self) -> Option<Self::Item<'_>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the parameter type `T` must be valid for the anonymous lifetime as defined here...
--> src/main.rs:9:19
|
9 | async fn next(&mut self) -> Option<Self::Item<'_>>;
| ^
note: ...so that the type `LendingIter<T>` will meet its required lifetime bounds
--> src/main.rs:29:5
|
29 | async fn next(&mut self) -> Option<Self::Item<'_>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0311`.
error: could not compile `playground` (bin "playground") due to previous error
I have a feeling async traits no longer play nice with lifetime GATs?
Meta
Tested on the playground using the current nightly:
nightly-2023-07-16 0e8e857b11f60a785aea
cc/ @rust-lang/wg-async, @compiler-errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
Type
Projects
Status
Done