diff options
Diffstat (limited to 'library/coretests/tests/ptr.rs')
| -rw-r--r-- | library/coretests/tests/ptr.rs | 12 |
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. }; } |
