]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/issue-19244.rs
New upstream version 1.19.0+dfsg1
[rustc.git] / src / test / run-pass / issue-19244.rs
1 // Copyright 2014 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
12 struct MyStruct { field: usize }
13 struct Nested { nested: MyStruct }
14 struct Mix2 { nested: ((usize,),) }
15
16 const STRUCT: MyStruct = MyStruct { field: 42 };
17 const TUP: (usize,) = (43,);
18 const NESTED_S: Nested = Nested { nested: MyStruct { field: 5 } };
19 const NESTED_T: ((usize,),) = ((4,),);
20 const MIX_1: ((Nested,),) = ((Nested { nested: MyStruct { field: 3 } },),);
21 const MIX_2: Mix2 = Mix2 { nested: ((2,),) };
22 const INSTANT_1: usize = (MyStruct { field: 1 }).field;
23 const INSTANT_2: usize = (0,).0;
24
25 fn main() {
26 let a = [0; STRUCT.field];
27 let b = [0; TUP.0];
28 let c = [0; NESTED_S.nested.field];
29 let d = [0; (NESTED_T.0).0];
30 let e = [0; (MIX_1.0).0.nested.field];
31 let f = [0; (MIX_2.nested.0).0];
32 let g = [0; INSTANT_1];
33 let h = [0; INSTANT_2];
34
35 assert_eq!(a.len(), 42);
36 assert_eq!(b.len(), 43);
37 assert_eq!(c.len(), 5);
38 assert_eq!(d.len(), 4);
39 assert_eq!(e.len(), 3);
40 assert_eq!(f.len(), 2);
41 assert_eq!(g.len(), 1);
42 assert_eq!(h.len(), 0);
43 }