1 // Test that we can derive lifetime bounds on type parameters
2 // from trait inheritance.
4 trait Static : 'static { }
9 x: Option<&'a mut &'a isize>
12 fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { }
14 // In all of these cases, we can derive a bound for A that is longer
15 // than 'a based on the trait bound of A:
17 fn foo1<'a,A:Static>(x: Inv<'a>, a: A) {
21 fn foo2<'a,A:Static>(x: Inv<'static>, a: A) {
25 fn foo3<'a,A:Is<'a>>(x: Inv<'a>, a: A) {
29 // In these cases, there is no trait bound, so we cannot derive any
30 // bound for A and we get an error:
32 fn bar1<'a,A>(x: Inv<'a>, a: A) {
33 check_bound(x, a) //~ ERROR parameter type `A` may not live long enough
36 fn bar2<'a,'b,A:Is<'b>>(x: Inv<'a>, y: Inv<'b>, a: A) {
37 check_bound(x, a) //~ ERROR parameter type `A` may not live long enough