rust/src/test/ui/nll/ty-outlives/projection-body.rs

28 lines
458 B
Rust
Raw Normal View History

// Test that when we infer the lifetime to a subset of the fn body, it
// works out.
2018-09-24 14:36:50 -05:00
//
// build-pass (FIXME(62277): could be check-pass?)
trait MyTrait<'a> {
type Output;
}
fn foo1<T>()
where
for<'x> T: MyTrait<'x>,
{
// Here the region `'c` in `<T as MyTrait<'c>>::Output` will be
// inferred to a subset of the fn body.
let x = bar::<T::Output>();
drop(x);
}
fn bar<'a, T>() -> &'a ()
where
T: 'a,
{
&()
}
fn main() {}