Closed
Description
The following fails to compile:
pub trait Iter {
type Item;
}
impl<'x, I> Iter for I
where
I: IntoIterator<Item = &'x str>,
{
type Item = &'x str;
}
pub struct Map<I>(I)
where
I: Iter,
I::Item: 'static;
fn test(_: Map<Vec<&str>>) {}
//~^ ERROR needs to satisfy a `'static` lifetime requirement
while changing the Iter
impl to use a paramter type X
instead of the lifetime 'x
makes it compile:
// ...
impl<X, I> Iter for I
where
I: IntoIterator<Item = X>,
{
type Item = X;
}
// ...
This is because we are ignoring projection predicates that constrain region variables while using those that constrain type variables:
rust/compiler/rustc_traits/src/implied_outlives_bounds.rs
Lines 86 to 94 in 8a7ca93
Should be fixed by #109482.