1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Check testing of equality constraints in a higher-ranked context.
13 pub trait TheTrait<T> {
16 fn get(&self, t: T) -> Self::A;
23 impl<'a> TheTrait<&'a isize> for IntStruct {
26 fn get(&self, t: &'a isize) -> &'a isize {
35 impl<'a> TheTrait<&'a isize> for UintStruct {
38 fn get(&self, t: &'a isize) -> &'a usize {
46 impl<'a> TheTrait<(&'a isize, &'a isize)> for Tuple {
49 fn get(&self, t: (&'a isize, &'a isize)) -> &'a isize {
55 where T : for<'x> TheTrait<&'x isize, A = &'x isize>
57 // ok for IntStruct, but not UintStruct
61 where T : for<'x> TheTrait<&'x isize, A = &'x usize>
63 // ok for UintStruct, but not IntStruct
67 where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize>
69 // not ok for tuple, two lifetimes and we pick first
73 where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize>
75 // not ok for tuple, two lifetimes and we pick second
79 where T : for<'x> TheTrait<(&'x isize, &'x isize), A = &'x isize>
85 where T : for<'x,'y> TheTrait<(&'x isize, &'y isize)>
87 // not ok for tuple, two lifetimes, and lifetime matching is invariant
92 foo::<UintStruct>(); //~ ERROR type mismatch
94 bar::<IntStruct>(); //~ ERROR type mismatch
99 //~| ERROR type mismatch
101 tuple_two::<Tuple>();
103 //~| ERROR type mismatch
105 tuple_three::<Tuple>();
107 tuple_four::<Tuple>();