]> git.lizzy.rs Git - rust.git/blob - tests/ui/mir/mir_constval_adts.rs
Rollup merge of #106605 - notriddle:notriddle/outdated-rustbook, r=GuillaumeGomez
[rust.git] / tests / ui / mir / mir_constval_adts.rs
1 // run-pass
2 #[derive(PartialEq, Debug)]
3 struct Point {
4     _x: i32,
5     _y: i32,
6 }
7
8 #[derive(PartialEq, Eq, Debug)]
9 struct Newtype<T>(T);
10
11 const STRUCT: Point = Point { _x: 42, _y: 42 };
12 const TUPLE1: (i32, i32) = (42, 42);
13 const TUPLE2: (&'static str, &'static str) = ("hello","world");
14 const PAIR_NEWTYPE: (Newtype<i32>, Newtype<i32>) = (Newtype(42), Newtype(42));
15
16 fn mir() -> (Point, (i32, i32), (&'static str, &'static str), (Newtype<i32>, Newtype<i32>)) {
17     let struct1 = STRUCT;
18     let tuple1 = TUPLE1;
19     let tuple2 = TUPLE2;
20     let pair_newtype = PAIR_NEWTYPE;
21     (struct1, tuple1, tuple2, pair_newtype)
22 }
23
24 const NEWTYPE: Newtype<&'static str> = Newtype("foobar");
25
26 fn test_promoted_newtype_str_ref() {
27     let x = &NEWTYPE;
28     assert_eq!(x, &Newtype("foobar"));
29 }
30
31 fn main(){
32     assert_eq!(mir(), (STRUCT, TUPLE1, TUPLE2, PAIR_NEWTYPE));
33     test_promoted_newtype_str_ref();
34 }