]> git.lizzy.rs Git - rust.git/blob - src/test/ui/coherence/coherence-where-clause.rs
Merge commit 'ea199bacef07213dbe008841b89c450e3bf0c638' into rustfmt-sync
[rust.git] / src / test / ui / coherence / coherence-where-clause.rs
1 // run-pass
2
3 use std::fmt::Debug;
4 use std::default::Default;
5
6 trait MyTrait {
7     fn get(&self) -> Self;
8 }
9
10 impl<T> MyTrait for T
11     where T : Default
12 {
13     fn get(&self) -> T {
14         Default::default()
15     }
16 }
17
18 #[derive(Clone, Copy, Debug, PartialEq)]
19 struct MyType {
20     dummy: usize
21 }
22
23 impl MyTrait for MyType {
24     fn get(&self) -> MyType { (*self).clone() }
25 }
26
27 fn test_eq<M>(m: M, n: M)
28 where M : MyTrait + Debug + PartialEq
29 {
30     assert_eq!(m.get(), n);
31 }
32
33 pub fn main() {
34     test_eq(0_usize, 0_usize);
35
36     let value = MyType { dummy: 256 + 22 };
37     test_eq(value, value);
38 }