Closed
Description
The code below doesn't compile anymore since nightly-2018-10-05:
use std::marker::PhantomData;
pub trait FooTypeHack: for<'a, 'b> FooType<'a, 'b> {}
impl<T: for<'a, 'b> FooType<'a, 'b>> FooTypeHack for T {}
pub trait FooType<'a, 'b: 'a> {
type Foo: Foo<'a, 'b>;
}
pub trait Foo<'a, 'b: 'a> {}
pub struct FooStruct<T>
where
T: FooTypeHack,
{
_t: PhantomData<T>,
}
impl<T> FooStruct<T>
where
T: FooTypeHack,
{
fn new() -> Self {
Self { _t: PhantomData }
}
}
pub struct FooTypeImpl {}
impl<'a, 'b: 'a> FooType<'a, 'b> for FooTypeImpl {
type Foo = FooImpl<'a, 'b>;
}
pub struct FooImpl<'a, 'b: 'a> {
_a: &'a PhantomData<&'b String>,
}
impl<'a, 'b> Foo<'a, 'b> for FooImpl<'a, 'b> {}
fn main() {
FooStruct::<FooTypeImpl>::new();
}
One would expect this to compile since it compiles on stable. Instead it throws:
error[E0279]: the requirement `for<'b, 'a> 'b : 'a` is not satisfied (`expected bound lifetime parameter 'a, found concrete lifetime`)
--> src/main.rs:40:5
AFAIK for<'b, 'a> 'b: 'a
can currently not be satisfied in rust therefore this should compile.