]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/mir_constval_adts.rs
Changed issue number to 36105
[rust.git] / src / test / run-pass / mir_constval_adts.rs
1 // Copyright 2016 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 #![feature(rustc_attrs)]
11
12 #[derive(PartialEq, Debug)]
13 struct Point {
14     _x: i32,
15     _y: i32,
16 }
17
18 #[derive(PartialEq, Eq, Debug)]
19 struct Newtype<T>(T);
20
21 const STRUCT: Point = Point { _x: 42, _y: 42 };
22 const TUPLE1: (i32, i32) = (42, 42);
23 const TUPLE2: (&'static str, &'static str) = ("hello","world");
24 const PAIR_NEWTYPE: (Newtype<i32>, Newtype<i32>) = (Newtype(42), Newtype(42));
25
26 #[rustc_mir]
27 fn mir() -> (Point, (i32, i32), (&'static str, &'static str), (Newtype<i32>, Newtype<i32>)) {
28     let struct1 = STRUCT;
29     let tuple1 = TUPLE1;
30     let tuple2 = TUPLE2;
31     let pair_newtype = PAIR_NEWTYPE;
32     (struct1, tuple1, tuple2, pair_newtype)
33 }
34
35 const NEWTYPE: Newtype<&'static str> = Newtype("foobar");
36
37 #[rustc_mir]
38 fn test_promoted_newtype_str_ref() {
39     let x = &NEWTYPE;
40     assert_eq!(x, &Newtype("foobar"));
41 }
42
43 fn main(){
44     assert_eq!(mir(), (STRUCT, TUPLE1, TUPLE2, PAIR_NEWTYPE));
45     test_promoted_newtype_str_ref();
46 }
47