diff options
| author | Oli Scherer <github333195615777966@oli-obk.de> | 2025-01-08 14:21:40 +0000 |
|---|---|---|
| committer | Oli Scherer <github333195615777966@oli-obk.de> | 2025-01-10 08:27:41 +0000 |
| commit | aec51564a55375e7fcf52bfccef226381f220bb5 (patch) | |
| tree | 148120dfc6909614ade90af6c500682c5454ee37 /tests/codegen | |
| parent | 88ab2d8acb342a36324103b6f95ec1335db27d7d (diff) | |
| download | rust-aec51564a55375e7fcf52bfccef226381f220bb5.tar.gz rust-aec51564a55375e7fcf52bfccef226381f220bb5.zip | |
Add regression test for option initialization
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/slice-init.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/codegen/slice-init.rs b/tests/codegen/slice-init.rs index 8126bf84618..a01b432add6 100644 --- a/tests/codegen/slice-init.rs +++ b/tests/codegen/slice-init.rs @@ -63,6 +63,34 @@ pub fn nonzero_integer_array() { opaque(&x); } +const N: usize = 100; + +// FIXME: The two bytes of the u16 are the same, so we should +// just use memset, too. +// CHECK-LABEL: @u16_init_one_bytes +#[no_mangle] +pub fn u16_init_one_bytes() -> [u16; N] { + // CHECK-NOT: select + // CHECK: br + // CHECK-NOT: switch + // CHECK: icmp + // CHECK-NOT: call void @llvm.memset.p0 + [const { u16::from_be_bytes([1, 1]) }; N] +} + +// FIXME: undef bytes can just be initialized with the same value as the +// defined bytes, if the defines bytes are all the same. +// CHECK-LABEL: @option_none_init +#[no_mangle] +pub fn option_none_init() -> [Option<u8>; N] { + // CHECK-NOT: select + // CHECK: br label %repeat_loop_header{{.*}} + // CHECK-NOT: switch + // CHECK: icmp + // CHECK-NOT: call void @llvm.memset.p0 + [None; N] +} + // Use an opaque function to prevent rustc from removing useless drops. #[inline(never)] pub fn opaque(_: impl Sized) {} |
