// Errors if you use this alias
// type Input<'a, This> = <This as HigherMatcher<'a>>::Input;
interesting.. but that’s a soundness issue, actually!!
use std::marker::PhantomData;
trait HigherMatcher<'a, _Outlives = &'a Self> {
type Input: Copy;
}
type Input<'a, This> = <This as HigherMatcher<'a>>::Input;
impl HigherMatcher<'_> for &'_ () {
type Input = ();
}
fn foo<'a>(y: &'a str) -> &'static str {
let x: PhantomData<Input<'static, &'a ()>> = PhantomData;
bar::<'a>(y, x)
}
fn bar<'a>(y: &'a str, x: PhantomData<Input<'static, &'a ()>>) -> &'static str
where
'a: 'a,
{
baz::<'a>(y, x)
}
fn baz<'a>(y: &'a str, x: PhantomData<<&'a () as HigherMatcher<'static>>::Input>) -> &'static str
where
'a: 'a,
{
qux(y)
}
fn qux(y: &'static str) -> &'static str {
y
}
fn main() {
let x = String::from("Hello World!");
let y = foo(&x);
drop(x);
println!("{}", y);
}