about summary refs log tree commit diff
path: root/library/coretests/tests/ptr.rs
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-07-17 20:00:19 +0200
committerRalf Jung <post@ralfj.de>2025-07-30 08:13:58 +0200
commitba5b6b9ec472dc32bdaa8b18c22d30bd6abf7ebc (patch)
tree212b535aaa7414d1336c8817dc8db1a0adbd670c /library/coretests/tests/ptr.rs
parent051d0e8a957c98f87ddaf6295c3a3ecd88742ff9 (diff)
downloadrust-ba5b6b9ec472dc32bdaa8b18c22d30bd6abf7ebc.tar.gz
rust-ba5b6b9ec472dc32bdaa8b18c22d30bd6abf7ebc.zip
const-eval: full support for pointer fragments
Diffstat (limited to 'library/coretests/tests/ptr.rs')
-rw-r--r--library/coretests/tests/ptr.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/library/coretests/tests/ptr.rs b/library/coretests/tests/ptr.rs
index 197a14423b5..c13fb96a67f 100644
--- a/library/coretests/tests/ptr.rs
+++ b/library/coretests/tests/ptr.rs
@@ -936,22 +936,18 @@ fn test_const_swap_ptr() {
         assert!(*s1.0.ptr == 666);
         assert!(*s2.0.ptr == 1);
 
-        // Swap them back, again as an array.
+        // Swap them back, byte-for-byte
         unsafe {
             ptr::swap_nonoverlapping(
-                ptr::from_mut(&mut s1).cast::<T>(),
-                ptr::from_mut(&mut s2).cast::<T>(),
-                1,
+                ptr::from_mut(&mut s1).cast::<u8>(),
+                ptr::from_mut(&mut s2).cast::<u8>(),
+                size_of::<A>(),
             );
         }
 
         // Make sure they still work.
         assert!(*s1.0.ptr == 1);
         assert!(*s2.0.ptr == 666);
-
-        // This is where we'd swap again using a `u8` type and a `count` of `size_of::<T>()` if it
-        // were not for the limitation of `swap_nonoverlapping` around pointers crossing multiple
-        // elements.
     };
 }