]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | // run-pass |
0731742a XL |
2 | // revisions: old re |
3 | ||
4 | #![cfg_attr(re, feature(re_rebalance_coherence))] | |
5 | ||
85aaf69f | 6 | use std::fmt::Debug; |
1a4d82fc JJ |
7 | use std::default::Default; |
8 | ||
9 | trait MyTrait { | |
10 | fn get(&self) -> Self; | |
11 | } | |
12 | ||
13 | impl<T> MyTrait for T | |
14 | where T : Default | |
15 | { | |
16 | fn get(&self) -> T { | |
17 | Default::default() | |
18 | } | |
19 | } | |
20 | ||
85aaf69f | 21 | #[derive(Clone, Copy, Debug, PartialEq)] |
1a4d82fc | 22 | struct MyType { |
c34b1796 | 23 | dummy: usize |
1a4d82fc JJ |
24 | } |
25 | ||
1a4d82fc JJ |
26 | impl MyTrait for MyType { |
27 | fn get(&self) -> MyType { (*self).clone() } | |
28 | } | |
29 | ||
30 | fn test_eq<M>(m: M, n: M) | |
85aaf69f | 31 | where M : MyTrait + Debug + PartialEq |
1a4d82fc JJ |
32 | { |
33 | assert_eq!(m.get(), n); | |
34 | } | |
35 | ||
36 | pub fn main() { | |
85aaf69f | 37 | test_eq(0_usize, 0_usize); |
1a4d82fc JJ |
38 | |
39 | let value = MyType { dummy: 256 + 22 }; | |
40 | test_eq(value, value); | |
41 | } |