compare_method_predicate_entailment
is missing implied bounds from higher-ranked GAT #133805
Open
Description
I tried this code (from tests/ui/generic-associated-types/extended/lending_iterator.rs
):
pub trait FromLendingIterator<A>: Sized {
fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self;
}
impl<A> FromLendingIterator<A> for Vec<A> {
fn from_iter<I: for<'x> LendingIterator<Item<'x> = A>>(mut iter: I) -> Self {
let mut v = vec![];
while let Some(item) = iter.next() {
v.push(item);
}
v
}
}
pub trait LendingIterator {
type Item<'z>
where
Self: 'z;
fn next(&mut self) -> Option<Self::Item<'_>>;
fn collect<A, B: FromLendingIterator<A>>(self) -> B
where
Self: Sized,
Self: for<'q> LendingIterator<Item<'q> = A>,
{
<B as FromLendingIterator<A>>::from_iter(self)
}
}
I expected to see this happen: Pass (probably?)
Instead, this happened:
error[E0276]: impl has stricter requirements than trait
--> $DIR/lending_iterator.rs:6:45
|
LL | fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self;
| ------------------------------------------------------------------------ definition of `from_iter` from trait
...
LL | fn from_iter<I: for<'x> LendingIterator<Item<'x> = A>>(mut iter: I) -> Self {
| ^^^^^^^^^^^^ impl has extra requirement `I: 'x`
error: `Self` does not live long enough
--> $DIR/lending_iterator.rs:27:9
|
LL | <B as FromLendingIterator<A>>::from_iter(self)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0276`.
Activity