mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 14:31:55 +00:00
35 lines
620 B
Rust
35 lines
620 B
Rust
// 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() {}
|