rust/tests/codegen/issues/issue-56927.rs
Nicholas Nethercote 72800d3b89 Run rustfmt on tests/codegen/.
Except for `simd-intrinsic/`, which has a lot of files containing
multiple types like `u8x64` which really are better when hand-formatted.

There is a surprising amount of two-space indenting in this directory.

Non-trivial changes:
- `rustfmt::skip` needed in `debug-column.rs` to preserve meaning of the
  test.
- `rustfmt::skip` used in a few places where hand-formatting read more
  nicely: `enum/enum-match.rs`
- Line number adjustments needed for the expected output of
  `debug-column.rs` and `coroutine-debug.rs`.
2024-05-31 15:56:43 +10:00

44 lines
879 B
Rust

//@ compile-flags: -C no-prepopulate-passes
#![crate_type = "rlib"]
#[repr(align(16))]
pub struct S {
arr: [u32; 4],
}
// CHECK-LABEL: @test1
// CHECK: store i32 0, ptr %{{.+}}, align 16
// CHECK: store i32 1, ptr %{{.+}}, align 4
// CHECK: store i32 2, ptr %{{.+}}, align 8
// CHECK: store i32 3, ptr %{{.+}}, align 4
#[no_mangle]
pub fn test1(s: &mut S) {
s.arr[0] = 0;
s.arr[1] = 1;
s.arr[2] = 2;
s.arr[3] = 3;
}
// CHECK-LABEL: @test2
// CHECK: store i32 4, ptr %{{.+}}, align 4
#[allow(unconditional_panic)]
#[no_mangle]
pub fn test2(s: &mut S) {
s.arr[usize::MAX / 4 + 1] = 4;
}
// CHECK-LABEL: @test3
// CHECK: store i32 5, ptr %{{.+}}, align 4
#[no_mangle]
pub fn test3(s: &mut S, i: usize) {
s.arr[i] = 5;
}
// CHECK-LABEL: @test4
// CHECK: store i32 6, ptr %{{.+}}, align 4
#[no_mangle]
pub fn test4(s: &mut S) {
s.arr = [6; 4];
}