]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/eq-multidispatch.rs
New upstream version 1.19.0+dfsg1
[rustc.git] / src / test / run-pass / eq-multidispatch.rs
CommitLineData
1a4d82fc
JJ
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.
4//
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.
10
c34b1796 11
62682a34 12#[derive(PartialEq, Debug)]
1a4d82fc 13struct Bar;
62682a34 14#[derive(Debug)]
1a4d82fc 15struct Baz;
62682a34 16#[derive(Debug)]
1a4d82fc 17struct Foo;
62682a34 18#[derive(Debug)]
1a4d82fc
JJ
19struct Fu;
20
21impl PartialEq for Baz { fn eq(&self, _: &Baz) -> bool { true } }
22
23impl PartialEq<Fu> for Foo { fn eq(&self, _: &Fu) -> bool { true } }
24impl PartialEq<Foo> for Fu { fn eq(&self, _: &Foo) -> bool { true } }
25
26impl PartialEq<Bar> for Foo { fn eq(&self, _: &Bar) -> bool { false } }
27impl PartialEq<Foo> for Bar { fn eq(&self, _: &Foo) -> bool { false } }
28
29fn main() {
30 assert!(Bar != Foo);
31 assert!(Foo != Bar);
32
62682a34 33 assert_eq!(Bar, Bar);
1a4d82fc 34
62682a34 35 assert_eq!(Baz, Baz);
1a4d82fc 36
62682a34
SL
37 assert_eq!(Foo, Fu);
38 assert_eq!(Fu, Foo);
1a4d82fc 39}