rust/tests/ui/nll/ty-outlives/projection-where-clause-none.rs
2023-01-11 09:32:08 +00:00

25 lines
463 B
Rust

// Test that we are NOT able to establish that `<T as
// MyTrait<'a>>::Output: 'a` outlives `'a` here -- we have only one
// recourse, which is to prove that `T: 'a` and `'a: 'a`, but we don't
// know that `T: 'a`.
trait MyTrait<'a> {
type Output;
}
fn foo<'a, T>() -> &'a ()
where
T: MyTrait<'a>,
{
bar::<T::Output>() //~ ERROR the parameter type `T` may not live long enough
}
fn bar<'a, T>() -> &'a ()
where
T: 'a,
{
&()
}
fn main() {}