1 // Check testing of equality constraints in a higher-ranked context.
3 pub trait TheTrait<T> {
6 fn get(&self, t: T) -> Self::A;
13 impl<'a> TheTrait<&'a isize> for IntStruct {
16 fn get(&self, t: &'a isize) -> &'a isize {
25 impl<'a> TheTrait<&'a isize> for UintStruct {
28 fn get(&self, t: &'a isize) -> &'a usize {
35 impl<'a> TheTrait<(&'a isize, &'a isize)> for Tuple {
38 fn get(&self, t: (&'a isize, &'a isize)) -> &'a isize {
45 T: for<'x> TheTrait<&'x isize, A = &'x isize>,
47 // ok for IntStruct, but not UintStruct
52 T: for<'x> TheTrait<&'x isize, A = &'x usize>,
54 // ok for UintStruct, but not IntStruct
59 T: for<'x, 'y> TheTrait<(&'x isize, &'y isize), A = &'x isize>,
61 // not ok for tuple, two lifetimes and we pick first
66 T: for<'x, 'y> TheTrait<(&'x isize, &'y isize), A = &'y isize>,
68 // not ok for tuple, two lifetimes and we pick second
73 T: for<'x> TheTrait<(&'x isize, &'x isize), A = &'x isize>,
80 T: for<'x, 'y> TheTrait<(&'x isize, &'y isize)>,
82 // not ok for tuple, two lifetimes, and lifetime matching is invariant
87 foo::<UintStruct>(); //~ ERROR type mismatch
91 bar::<IntStruct>(); //~ ERROR type mismatch
95 pub fn call_tuple_one() {
97 //~^ ERROR implementation of `TheTrait` is not general enough
98 //~| ERROR implementation of `TheTrait` is not general enough
101 pub fn call_tuple_two() {
102 tuple_two::<Tuple>();
103 //~^ ERROR implementation of `TheTrait` is not general enough
104 //~| ERROR implementation of `TheTrait` is not general enough
107 pub fn call_tuple_three() {
108 tuple_three::<Tuple>();
111 pub fn call_tuple_four() {
112 tuple_four::<Tuple>();
113 //~^ ERROR implementation of `TheTrait` is not general enough