about summary refs log tree commit diff
path: root/tests/codegen-llvm/issues/issue-98294-get-mut-copy-from-slice-opt.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/codegen-llvm/issues/issue-98294-get-mut-copy-from-slice-opt.rs')
-rw-r--r--tests/codegen-llvm/issues/issue-98294-get-mut-copy-from-slice-opt.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/codegen-llvm/issues/issue-98294-get-mut-copy-from-slice-opt.rs b/tests/codegen-llvm/issues/issue-98294-get-mut-copy-from-slice-opt.rs
new file mode 100644
index 00000000000..76adcf9fd45
--- /dev/null
+++ b/tests/codegen-llvm/issues/issue-98294-get-mut-copy-from-slice-opt.rs
@@ -0,0 +1,17 @@
+//@ compile-flags: -Copt-level=3
+
+#![crate_type = "lib"]
+
+// There should be no calls to panic / len_mismatch_fail.
+
+#[no_mangle]
+pub fn test(a: &mut [u8], offset: usize, bytes: &[u8]) {
+    // CHECK-LABEL: @test(
+    // CHECK-NOT: call
+    // CHECK: call void @llvm.memcpy
+    // CHECK-NOT: call
+    // CHECK: }
+    if let Some(dst) = a.get_mut(offset..offset + bytes.len()) {
+        dst.copy_from_slice(bytes);
+    }
+}