about summary refs log tree commit diff
path: root/tests/mir-opt/issue_72181.rs
blob: dea8ecbd3ec7b0fc8b104b2fe600c4d63e8465c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// skip-filecheck
//@ compile-flags: -Z mir-opt-level=1
// Regression test for #72181, this ICE requires `-Z mir-opt-level=1` flags.

use std::mem;

#[derive(Copy, Clone)]
enum Never {}

union Foo {
    a: u64,
    b: Never,
}

// EMIT_MIR issue_72181.foo.built.after.mir
fn foo(xs: [(Never, u32); 1]) -> u32 {
    xs[0].1
}

// EMIT_MIR issue_72181.bar.built.after.mir
fn bar([(_, x)]: [(Never, u32); 1]) -> u32 {
    x
}

// EMIT_MIR issue_72181.main.built.after.mir
fn main() {
    let _ = mem::size_of::<Foo>();

    let f = [Foo { a: 42 }, Foo { a: 10 }];
    let _ = unsafe { f[0].a };
}