rust/tests/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
620 B
Rust
Raw Normal View History

// Test that we are able to establish that `<T as
// MyTrait<'a>>::Output` outlives `'b` here. We need to prove however
// that `<T as MyTrait<'a>>::Output` outlives `'a`, so we also have to
// prove that `'b: 'a`.
trait MyTrait<'a> {
type Output;
}
fn foo1<'a, 'b, T>() -> &'a ()
where
T: MyTrait<'a>,
<T as MyTrait<'a>>::Output: 'b,
{
bar::<T::Output>() //~ ERROR may not live long enough
}
fn foo2<'a, 'b, T>() -> &'a ()
where
T: MyTrait<'a>,
<T as MyTrait<'a>>::Output: 'b,
'b: 'a,
{
bar::<T::Output>() // OK
}
fn bar<'a, T>() -> &'a ()
where
T: 'a,
{
&()
}
fn main() {}