2019-07-26 16:54:25 -05:00
|
|
|
// run-pass
|
2016-08-15 13:28:17 -05:00
|
|
|
// `#[derive(Trait)]` works for empty structs/variants with braces or parens.
|
2016-02-22 12:24:32 -06:00
|
|
|
|
|
|
|
#![feature(rustc_private)]
|
|
|
|
|
2020-07-04 10:20:24 -05:00
|
|
|
extern crate rustc_macros;
|
2020-06-02 14:46:42 -05:00
|
|
|
extern crate rustc_serialize;
|
2024-01-01 09:13:39 -06:00
|
|
|
extern crate rustc_span;
|
2016-02-22 12:24:32 -06:00
|
|
|
|
2022-12-12 13:37:28 -06:00
|
|
|
// Necessary to pull in object code as the rest of the rustc crates are shipped only as rmeta
|
|
|
|
// files.
|
|
|
|
#[allow(unused_extern_crates)]
|
|
|
|
extern crate rustc_driver;
|
|
|
|
|
2020-07-04 10:20:24 -05:00
|
|
|
use rustc_macros::{Decodable, Encodable};
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug, Encodable, Decodable)]
|
2016-02-22 12:24:32 -06:00
|
|
|
struct S {}
|
|
|
|
|
2020-07-04 10:20:24 -05:00
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug, Encodable, Decodable)]
|
2016-08-15 13:28:17 -05:00
|
|
|
struct Z();
|
|
|
|
|
2020-07-04 10:20:24 -05:00
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Encodable, Decodable)]
|
2016-02-22 12:24:32 -06:00
|
|
|
enum E {
|
|
|
|
V {},
|
|
|
|
U,
|
2016-08-15 13:28:17 -05:00
|
|
|
W(),
|
2016-02-22 12:24:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let s = S {};
|
|
|
|
let s1 = s;
|
|
|
|
let s2 = s.clone();
|
|
|
|
assert_eq!(s, s1);
|
|
|
|
assert_eq!(s, s2);
|
|
|
|
assert!(!(s < s1));
|
|
|
|
assert_eq!(format!("{:?}", s), "S");
|
|
|
|
|
2016-08-15 13:28:17 -05:00
|
|
|
let z = Z();
|
|
|
|
let z1 = z;
|
|
|
|
let z2 = z.clone();
|
|
|
|
assert_eq!(z, z1);
|
|
|
|
assert_eq!(z, z2);
|
|
|
|
assert!(!(z < z1));
|
|
|
|
assert_eq!(format!("{:?}", z), "Z");
|
|
|
|
|
2016-02-22 12:24:32 -06:00
|
|
|
let e = E::V {};
|
|
|
|
let e1 = e;
|
|
|
|
let e2 = e.clone();
|
|
|
|
assert_eq!(e, e1);
|
|
|
|
assert_eq!(e, e2);
|
|
|
|
assert!(!(e < e1));
|
|
|
|
assert_eq!(format!("{:?}", e), "V");
|
2016-08-15 13:28:17 -05:00
|
|
|
|
|
|
|
let e = E::W();
|
|
|
|
let e1 = e;
|
|
|
|
let e2 = e.clone();
|
|
|
|
assert_eq!(e, e1);
|
|
|
|
assert_eq!(e, e2);
|
|
|
|
assert!(!(e < e1));
|
|
|
|
assert_eq!(format!("{:?}", e), "W");
|
2016-02-22 12:24:32 -06:00
|
|
|
}
|