1 // Check that explicit region bounds are allowed on the various
2 // nominal types (but not on other types) and that they are type
5 struct Inv<'a> { // invariant w/r/t 'a
9 pub trait Foo<'a, 't> {
10 fn no_bound<'b>(self, b: Inv<'b>);
11 fn has_bound<'b:'a>(self, b: Inv<'b>);
12 fn wrong_bound1<'b,'c,'d:'a+'b>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>);
13 fn wrong_bound2<'b,'c,'d:'a+'b>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>);
14 fn okay_bound<'b,'c,'d:'a+'b+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>);
15 fn another_bound<'x: 'a>(self, x: Inv<'x>, y: Inv<'t>);
18 impl<'a, 't> Foo<'a, 't> for &'a isize {
19 fn no_bound<'b:'a>(self, b: Inv<'b>) {
20 //~^ ERROR lifetime parameters or bounds on method `no_bound` do not match
23 fn has_bound<'b>(self, b: Inv<'b>) {
24 //~^ ERROR lifetime parameters or bounds on method `has_bound` do not match
27 fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) {
28 //~^ ERROR method not compatible with trait
29 //~| ERROR method not compatible with trait
31 // Note: This is a terrible error message. It is caused
32 // because, in the trait, 'b is early bound, and in the impl,
33 // 'c is early bound, so -- after substitution -- the
34 // lifetimes themselves look isomorphic. We fail because the
35 // lifetimes that appear in the types are in the wrong
36 // order. This should really be fixed by keeping more
37 // information about the lifetime declarations in the trait so
38 // that we can compare better to the impl, even in cross-crate
42 fn wrong_bound2(self, b: Inv, c: Inv, d: Inv) {
43 //~^ ERROR lifetime parameters or bounds on method `wrong_bound2` do not match the trait
46 fn okay_bound<'b,'c,'e:'b+'c>(self, b: Inv<'b>, c: Inv<'c>, e: Inv<'e>) {
49 fn another_bound<'x: 't>(self, x: Inv<'x>, y: Inv<'t>) {