]>
git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/trait-bounds-impl-comparison-1.rs
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,
23 fn test_error1_fn
<T
: Eq
>(&self);
24 fn test_error2_fn
<T
: Eq
+ Ord
>(&self);
25 fn test_error3_fn
<T
: Eq
+ Ord
>(&self);
26 fn test3_fn
<T
: Eq
+ Ord
>(&self);
27 fn test4_fn
<T
: Eq
+ Ord
>(&self);
28 fn test_error5_fn
<T
: A
>(&self);
29 fn test6_fn
<T
: A
+ Eq
>(&self);
30 fn test_error7_fn
<T
: A
>(&self);
31 fn test_error8_fn
<T
: B
>(&self);
35 // invalid bound for T, was defined as Eq in trait
36 fn test_error1_fn
<T
: Ord
>(&self) {}
37 //~^ ERROR the requirement `T: std::cmp::Ord` appears on the impl
39 // invalid bound for T, was defined as Eq + Ord in trait
40 fn test_error2_fn
<T
: Eq
+ B
>(&self) {}
41 //~^ ERROR the requirement `T: B` appears on the impl
43 // invalid bound for T, was defined as Eq + Ord in trait
44 fn test_error3_fn
<T
: B
+ Eq
>(&self) {}
45 //~^ ERROR the requirement `T: B` appears on the impl
47 // multiple bounds, same order as in trait
48 fn test3_fn
<T
: Ord
+ Eq
>(&self) {}
50 // multiple bounds, different order as in trait
51 fn test4_fn
<T
: Eq
+ Ord
>(&self) {}
53 // parameters in impls must be equal or more general than in the defining trait
54 fn test_error5_fn
<T
: B
>(&self) {}
55 //~^ ERROR the requirement `T: B` appears on the impl
57 // bound `std::cmp::Eq` not enforced by this implementation, but this is OK
58 fn test6_fn
<T
: A
>(&self) {}
60 fn test_error7_fn
<T
: A
+ Eq
>(&self) {}
61 //~^ ERROR the requirement `T: std::cmp::Eq` appears on the impl
63 fn test_error8_fn
<T
: C
>(&self) {}
64 //~^ ERROR the requirement `T: C` appears on the impl
68 fn get(&self) -> T { loop { }
}
72 fn method
<G
:Getter
<isize>>(&self);
75 impl Trait
for usize {
76 fn method
<G
: Getter
<usize>>(&self) {}
77 //~^ ERROR `G: Getter<usize>` appears on the impl method