about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-07-07 16:54:44 +0200
committerRalf Jung <post@ralfj.de>2023-07-07 16:54:44 +0200
commit7a83ef82da92d81be83d430602778f4f4c8fb439 (patch)
treefbe69d57ce652cf0dcd466de94095c4c9ab1ef6c /compiler/rustc_const_eval/src
parent1a449dcfd25143f7e1f6b6f5ddf1c12af361e2ff (diff)
downloadrust-7a83ef82da92d81be83d430602778f4f4c8fb439.tar.gz
rust-7a83ef82da92d81be83d430602778f4f4c8fb439.zip
miri: check that assignments do not self-overlap
Diffstat (limited to 'compiler/rustc_const_eval/src')
-rw-r--r--compiler/rustc_const_eval/src/interpret/place.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs
index 24c1fe43d0c..ca1106384fd 100644
--- a/compiler/rustc_const_eval/src/interpret/place.rs
+++ b/compiler/rustc_const_eval/src/interpret/place.rs
@@ -700,8 +700,13 @@ where
             assert_eq!(src.layout.size, dest.layout.size);
         }
 
+        // Setting `nonoverlapping` here only has an effect when we don't hit the fast-path above,
+        // but that should at least match what LLVM does where `memcpy` is also only used when the
+        // type does not have Scalar/ScalarPair layout.
+        // (Or as the `Assign` docs put it, assignments "not producing primitives" must be
+        // non-overlapping.)
         self.mem_copy(
-            src.ptr, src.align, dest.ptr, dest.align, dest_size, /*nonoverlapping*/ false,
+            src.ptr, src.align, dest.ptr, dest.align, dest_size, /*nonoverlapping*/ true,
         )
     }