Open
Description
I tried this code:
#![feature(generic_associated_types)]
#![feature(type_alias_impl_trait)]
use std::future::Future;
pub trait FutureIterator: 'static {
type Iterator;
type Future<'s, 'cx>: Future<Output = Self::Iterator> + Send + 'cx
where
's: 'cx;
fn get_iter<'s, 'cx>(&'s self, info: &'cx ()) -> Self::Future<'s, 'cx>;
}
trait IterCaller: 'static {
type Future1<'cx>: Future<Output = ()> + Send + 'cx;
type Future2<'cx>: Future<Output = ()> + Send + 'cx;
fn call_1<'s, 'cx>(&'s self, cx: &'cx ()) -> Self::Future1<'cx>
where
's: 'cx;
fn call_2<'s, 'cx>(&'s self, cx: &'cx ()) -> Self::Future2<'cx>
where
's: 'cx;
}
struct UseIter<FI1, FI2> {
fi_1: FI1,
fi_2: FI2,
}
impl<FI1, FI2> IterCaller for UseIter<FI1, FI2>
where
FI1: FutureIterator + 'static + Send + Sync,
for<'s, 'cx> FI1::Future<'s, 'cx>: Send,
FI2: FutureIterator + 'static + Send + Sync,
{
type Future1<'cx> = impl Future<Output = ()> + Send + 'cx
where
Self: 'cx;
type Future2<'cx> = impl Future<Output = ()> + Send + 'cx
where
Self: 'cx;
fn call_1<'s, 'cx>(&'s self, cx: &'cx ()) -> Self::Future1<'cx>
where
's: 'cx,
{
async {
self.fi_1.get_iter(cx).await;
}
}
fn call_2<'s, 'cx>(&'s self, cx: &'cx ()) -> Self::Future2<'cx>
where
's: 'cx,
{
async {
self.fi_2.get_iter(cx).await;
}
}
}
fn main() {}
I expected to see this happen: both type declaration of IterCaller::call_1
and IterCaller::call_2
pass the compiling
Instead, this happened:
error: higher-ranked lifetime error
--> src/main.rs:60:9
|
60 | / async {
61 | | self.fi_2.get_iter(cx).await;
62 | | }
| |_________^
Meta
rustc --version --verbose
:
rustc 1.64.0-nightly (f9cba6374 2022-07-31)
binary: rustc
commit-hash: f9cba63746d0fff816250b2ba7b706b5d4dcf000
commit-date: 2022-07-31
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6
Metadata
Metadata
Assignees
Labels
Area: Generic associated types (GATs)Area: Async & AwaitArea: CoroutinesArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Lifetimes / regionsAsync-await issues that have been triaged during a working group meeting.Category: This is a bug.Status: This bug is tracked inside the repo by a `known-bug` test.Relevant to the types team, which will review and decide on the PR/issue.