]> git.lizzy.rs Git - rust.git/blob - tests/ui/mir/mir_const_prop_tuple_field_reorder.rs
Rollup merge of #106707 - ehuss:remove-dupe-sha-1, r=Mark-Simulacrum
[rust.git] / tests / ui / mir / mir_const_prop_tuple_field_reorder.rs
1 // compile-flags: -Z mir-opt-level=3
2 // build-pass
3 #![crate_type="lib"]
4
5 // This used to ICE: const-prop did not account for field reordering of scalar pairs,
6 // and would generate a tuple like `(0x1337, VariantBar): (FooEnum, isize)`,
7 // causing assertion failures in codegen when trying to read 0x1337 at the wrong type.
8
9 pub enum FooEnum {
10     VariantBar,
11     VariantBaz,
12     VariantBuz,
13 }
14
15 pub fn wrong_index() -> isize {
16     let (_, b) = id((FooEnum::VariantBar, 0x1337));
17     b
18 }
19
20 pub fn wrong_index_two() -> isize {
21     let (_, (_, b)) = id(((), (FooEnum::VariantBar, 0x1338)));
22     b
23 }
24
25 fn id<T>(x: T) -> T {
26     x
27 }