]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/issue-56927.rs
Suggest defining type parameter when appropriate
[rust.git] / src / test / codegen / issue-56927.rs
1 // compile-flags: -C no-prepopulate-passes
2
3 #![crate_type="rlib"]
4 use std::usize;
5
6 #[repr(align(16))]
7 pub struct S {
8     arr: [u32; 4],
9 }
10
11 // CHECK-LABEL: @test1
12 // CHECK: store i32 0, i32* %{{.+}}, align 16
13 // CHECK: store i32 1, i32* %{{.+}}, align 4
14 // CHECK: store i32 2, i32* %{{.+}}, align 8
15 // CHECK: store i32 3, i32* %{{.+}}, align 4
16 #[no_mangle]
17 pub fn test1(s: &mut S) {
18     s.arr[0] = 0;
19     s.arr[1] = 1;
20     s.arr[2] = 2;
21     s.arr[3] = 3;
22 }
23
24 // CHECK-LABEL: @test2
25 // CHECK: store i32 4, i32* %{{.+}}, align 4
26 #[allow(const_err)]
27 #[no_mangle]
28 pub fn test2(s: &mut S) {
29     s.arr[usize::MAX / 4 + 1] = 4;
30 }
31
32 // CHECK-LABEL: @test3
33 // CHECK: store i32 5, i32* %{{.+}}, align 4
34 #[no_mangle]
35 pub fn test3(s: &mut S, i: usize) {
36     s.arr[i] = 5;
37 }
38
39 // CHECK-LABEL: @test4
40 // CHECK: store i32 6, i32* %{{.+}}, align 4
41 #[no_mangle]
42 pub fn test4(s: &mut S) {
43     s.arr = [6; 4];
44 }