]>
Commit | Line | Data |
---|---|---|
8bb4bdeb | 1 | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT |
223e47cc LB |
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 | ||
b7449926 | 11 | // run-pass |
ff7c6d11 XL |
12 | // compile-flags: -Zmir-opt-level=1 |
13 | ||
ea8adc8c | 14 | use std::mem; |
3b2f2976 | 15 | |
ff7c6d11 XL |
16 | #[derive(Copy, Clone)] |
17 | enum Never {} | |
18 | ||
19 | union Foo { | |
20 | a: u64, | |
21 | b: Never | |
22 | } | |
23 | ||
24 | fn foo(xs: [(Never, u32); 1]) -> u32 { xs[0].1 } | |
25 | ||
26 | fn bar([(_, x)]: [(Never, u32); 1]) -> u32 { x } | |
27 | ||
7453a54e | 28 | fn main() { |
ff7c6d11 XL |
29 | println!("{}", mem::size_of::<Foo>()); |
30 | ||
31 | let f = [Foo { a: 42 }, Foo { a: 10 }]; | |
32 | println!("{:?}", unsafe { f[0].a }); | |
223e47cc | 33 | } |