Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6166b0c

Browse files
committedNov 13, 2024
Update core CloneToUninit tests
1 parent e0c1c8b commit 6166b0c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed
 

‎library/core/tests/clone.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn test_clone_to_uninit_slice_success() {
2828

2929
let mut storage: MaybeUninit<[String; 3]> = MaybeUninit::uninit();
3030
let b: [String; 3] = unsafe {
31-
a[..].clone_to_uninit(storage.as_mut_ptr() as *mut [String]);
31+
a[..].clone_to_uninit(storage.as_mut_ptr().cast());
3232
storage.assume_init()
3333
};
3434

@@ -70,7 +70,7 @@ fn test_clone_to_uninit_slice_drops_on_panic() {
7070
let mut storage: MaybeUninit<[CountsDropsAndPanics; 3]> = MaybeUninit::uninit();
7171
// This should panic halfway through
7272
unsafe {
73-
a[..].clone_to_uninit(storage.as_mut_ptr() as *mut [CountsDropsAndPanics]);
73+
a[..].clone_to_uninit(storage.as_mut_ptr().cast());
7474
}
7575
})
7676
.unwrap_err();
@@ -89,13 +89,13 @@ fn test_clone_to_uninit_str() {
8989
let a = "hello";
9090

9191
let mut storage: MaybeUninit<[u8; 5]> = MaybeUninit::uninit();
92-
unsafe { a.clone_to_uninit(storage.as_mut_ptr() as *mut [u8] as *mut str) };
92+
unsafe { a.clone_to_uninit(storage.as_mut_ptr().cast()) };
9393
assert_eq!(a.as_bytes(), unsafe { storage.assume_init() }.as_slice());
9494

9595
let mut b: Box<str> = "world".into();
9696
assert_eq!(a.len(), b.len());
9797
assert_ne!(a, &*b);
98-
unsafe { a.clone_to_uninit(ptr::from_mut::<str>(&mut b)) };
98+
unsafe { a.clone_to_uninit(ptr::from_mut::<str>(&mut b).cast()) };
9999
assert_eq!(a, &*b);
100100
}
101101

@@ -104,13 +104,13 @@ fn test_clone_to_uninit_cstr() {
104104
let a = c"hello";
105105

106106
let mut storage: MaybeUninit<[u8; 6]> = MaybeUninit::uninit();
107-
unsafe { a.clone_to_uninit(storage.as_mut_ptr() as *mut [u8] as *mut CStr) };
107+
unsafe { a.clone_to_uninit(storage.as_mut_ptr().cast()) };
108108
assert_eq!(a.to_bytes_with_nul(), unsafe { storage.assume_init() }.as_slice());
109109

110110
let mut b: Box<CStr> = c"world".into();
111111
assert_eq!(a.count_bytes(), b.count_bytes());
112112
assert_ne!(a, &*b);
113-
unsafe { a.clone_to_uninit(ptr::from_mut::<CStr>(&mut b)) };
113+
unsafe { a.clone_to_uninit(ptr::from_mut::<CStr>(&mut b).cast()) };
114114
assert_eq!(a, &*b);
115115
}
116116

0 commit comments

Comments
 (0)
Failed to load comments.