]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass-fulldeps/empty-struct-braces-derive.rs
Auto merge of #54919 - alexcrichton:update-cargo, r=Mark-Simulacrum
[rust.git] / src / test / run-pass-fulldeps / empty-struct-braces-derive.rs
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
11 // `#[derive(Trait)]` works for empty structs/variants with braces or parens.
12
13 #![feature(rustc_private)]
14
15 extern crate serialize as rustc_serialize;
16
17 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash,
18          Default, Debug, RustcEncodable, RustcDecodable)]
19 struct S {}
20
21 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash,
22          Default, Debug, RustcEncodable, RustcDecodable)]
23 struct Z();
24
25 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash,
26          Debug, RustcEncodable, RustcDecodable)]
27 enum E {
28     V {},
29     U,
30     W(),
31 }
32
33 fn main() {
34     let s = S {};
35     let s1 = s;
36     let s2 = s.clone();
37     assert_eq!(s, s1);
38     assert_eq!(s, s2);
39     assert!(!(s < s1));
40     assert_eq!(format!("{:?}", s), "S");
41
42     let z = Z();
43     let z1 = z;
44     let z2 = z.clone();
45     assert_eq!(z, z1);
46     assert_eq!(z, z2);
47     assert!(!(z < z1));
48     assert_eq!(format!("{:?}", z), "Z");
49
50     let e = E::V {};
51     let e1 = e;
52     let e2 = e.clone();
53     assert_eq!(e, e1);
54     assert_eq!(e, e2);
55     assert!(!(e < e1));
56     assert_eq!(format!("{:?}", e), "V");
57
58     let e = E::W();
59     let e1 = e;
60     let e2 = e.clone();
61     assert_eq!(e, e1);
62     assert_eq!(e, e2);
63     assert!(!(e < e1));
64     assert_eq!(format!("{:?}", e), "W");
65 }