]>
Commit | Line | Data |
---|---|---|
7453a54e SL |
1 | // Copyright 2015 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 | ||
9e0c209e | 11 | // `#[derive(Trait)]` works for empty structs/variants with braces or parens. |
7453a54e | 12 | |
9e0c209e | 13 | #![feature(relaxed_adts)] |
7453a54e SL |
14 | #![feature(rustc_private)] |
15 | ||
16 | extern crate serialize as rustc_serialize; | |
17 | ||
18 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, | |
19 | Default, Debug, RustcEncodable, RustcDecodable)] | |
20 | struct S {} | |
21 | ||
9e0c209e SL |
22 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, |
23 | Default, Debug, RustcEncodable, RustcDecodable)] | |
24 | struct Z(); | |
25 | ||
7453a54e SL |
26 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, |
27 | Debug, RustcEncodable, RustcDecodable)] | |
28 | enum E { | |
29 | V {}, | |
30 | U, | |
9e0c209e | 31 | W(), |
7453a54e SL |
32 | } |
33 | ||
34 | fn main() { | |
35 | let s = S {}; | |
36 | let s1 = s; | |
37 | let s2 = s.clone(); | |
38 | assert_eq!(s, s1); | |
39 | assert_eq!(s, s2); | |
40 | assert!(!(s < s1)); | |
41 | assert_eq!(format!("{:?}", s), "S"); | |
42 | ||
9e0c209e SL |
43 | let z = Z(); |
44 | let z1 = z; | |
45 | let z2 = z.clone(); | |
46 | assert_eq!(z, z1); | |
47 | assert_eq!(z, z2); | |
48 | assert!(!(z < z1)); | |
49 | assert_eq!(format!("{:?}", z), "Z"); | |
50 | ||
7453a54e SL |
51 | let e = E::V {}; |
52 | let e1 = e; | |
53 | let e2 = e.clone(); | |
54 | assert_eq!(e, e1); | |
55 | assert_eq!(e, e2); | |
56 | assert!(!(e < e1)); | |
57 | assert_eq!(format!("{:?}", e), "V"); | |
9e0c209e SL |
58 | |
59 | let e = E::W(); | |
60 | let e1 = e; | |
61 | let e2 = e.clone(); | |
62 | assert_eq!(e, e1); | |
63 | assert_eq!(e, e2); | |
64 | assert!(!(e < e1)); | |
65 | assert_eq!(format!("{:?}", e), "W"); | |
7453a54e | 66 | } |