]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/coherence/coherence-where-clause.rs
New upstream version 1.33.0+dfsg1
[rustc.git] / src / test / run-pass / coherence / coherence-where-clause.rs
CommitLineData
b7449926 1// run-pass
0731742a
XL
2// revisions: old re
3
4#![cfg_attr(re, feature(re_rebalance_coherence))]
5
85aaf69f 6use std::fmt::Debug;
1a4d82fc
JJ
7use std::default::Default;
8
9trait MyTrait {
10 fn get(&self) -> Self;
11}
12
13impl<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 22struct MyType {
c34b1796 23 dummy: usize
1a4d82fc
JJ
24}
25
1a4d82fc
JJ
26impl MyTrait for MyType {
27 fn get(&self) -> MyType { (*self).clone() }
28}
29
30fn test_eq<M>(m: M, n: M)
85aaf69f 31where M : MyTrait + Debug + PartialEq
1a4d82fc
JJ
32{
33 assert_eq!(m.get(), n);
34}
35
36pub 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}