diff options
| author | bors <bors@rust-lang.org> | 2022-09-07 05:58:29 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-07 05:58:29 +0000 |
| commit | 0568b0a3de4eb37bf187eb61a9f017ae0018ad8f (patch) | |
| tree | b22ca17fba99bb7b8b2f0e2f7ee94df2a6b6831c | |
| parent | ff479b1f3c77e8312843e7de212253632f4c1a8a (diff) | |
| parent | cbf3b2432e612fca1db0f320003745d7adc431b9 (diff) | |
| download | rust-0568b0a3de4eb37bf187eb61a9f017ae0018ad8f.tar.gz rust-0568b0a3de4eb37bf187eb61a9f017ae0018ad8f.zip | |
Auto merge of #101232 - nikic:issue-98294, r=Mark-Simulacrum
Add test for #98294 Add a test to make that the failure condition for this pattern is optimized away. Fixes #98294.
| -rw-r--r-- | src/test/codegen/issue-98294-get-mut-copy-from-slice-opt.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/codegen/issue-98294-get-mut-copy-from-slice-opt.rs b/src/test/codegen/issue-98294-get-mut-copy-from-slice-opt.rs new file mode 100644 index 00000000000..7da29cd7952 --- /dev/null +++ b/src/test/codegen/issue-98294-get-mut-copy-from-slice-opt.rs @@ -0,0 +1,19 @@ +// min-llvm-version: 15.0.0 +// ignore-debug: The debug assertions get in the way +// compile-flags: -O + +#![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); + } +} |
