rust/tests/mir-opt/const_prop/slice_len.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
566 B
Rust
Raw Normal View History

2023-09-20 21:43:33 +00:00
// unit-test: GVN
2023-05-06 23:20:58 -04:00
// compile-flags: -Zmir-enable-passes=+InstSimplify
2023-12-02 21:04:15 +00:00
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// EMIT_MIR_FOR_EACH_BIT_WIDTH
2020-04-04 17:15:01 +00:00
2023-09-20 21:43:33 +00:00
// EMIT_MIR slice_len.main.GVN.diff
fn main() {
2023-12-02 21:04:15 +00:00
// CHECK-LABEL: fn main(
// CHECK: debug a => [[a:_.*]];
2023-09-20 21:43:33 +00:00
// CHECK: [[slice:_.*]] = const {{.*}} as &[u32] (PointerCoercion(Unsize));
// FIXME(cjgillot) simplify Len and projection into unsized slice.
// CHECK-NOT: assert(const true,
// CHECK: [[a]] = (*[[slice]])[1 of 2];
// CHECK-NOT: [[a]] = const 2_u32;
2023-12-02 21:04:15 +00:00
let a = (&[1u32, 2, 3] as &[u32])[1];
}