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 // Make sure rustc checks the type parameter bounds in implementations of traits,
21 fn test_error1_fn<T: Eq>(&self);
22 fn test_error2_fn<T: Eq + Ord>(&self);
23 fn test_error3_fn<T: Eq + Ord>(&self);
24 fn test3_fn<T: Eq + Ord>(&self);
25 fn test4_fn<T: Eq + Ord>(&self);
26 fn test_error5_fn<T: A>(&self);
27 fn test6_fn<T: A + Eq>(&self);
28 fn test_error7_fn<T: A>(&self);
29 fn test_error8_fn<T: B>(&self);
33 // invalid bound for T, was defined as Eq in trait
34 fn test_error1_fn<T: Ord>(&self) {}
35 //~^ ERROR the requirement `T : core::cmp::Ord` appears on the impl
37 // invalid bound for T, was defined as Eq + Ord in trait
38 fn test_error2_fn<T: Eq + B>(&self) {}
39 //~^ ERROR the requirement `T : B` appears on the impl
41 // invalid bound for T, was defined as Eq + Ord in trait
42 fn test_error3_fn<T: B + Eq>(&self) {}
43 //~^ ERROR the requirement `T : B` appears on the impl
45 // multiple bounds, same order as in trait
46 fn test3_fn<T: Ord + Eq>(&self) {}
48 // multiple bounds, different order as in trait
49 fn test4_fn<T: Eq + Ord>(&self) {}
51 // parameters in impls must be equal or more general than in the defining trait
52 fn test_error5_fn<T: B>(&self) {}
53 //~^ ERROR the requirement `T : B` appears on the impl
55 // bound `std::cmp::Eq` not enforced by this implementation, but this is OK
56 fn test6_fn<T: A>(&self) {}
58 fn test_error7_fn<T: A + Eq>(&self) {}
59 //~^ ERROR the requirement `T : core::cmp::Eq` appears on the impl
61 fn test_error8_fn<T: C>(&self) {}
62 //~^ ERROR the requirement `T : C` appears on the impl
69 fn method<G:Getter<isize>>();
72 impl Trait for usize {
73 fn method<G: Getter<usize>>() {}
74 //~^ G : Getter<usize>` appears on the impl method but not on the corresponding trait method