diff options
| author | Zachary S <zasample18+github@gmail.com> | 2024-11-13 13:42:41 -0600 |
|---|---|---|
| committer | Zachary S <zasample18+github@gmail.com> | 2024-11-13 13:42:41 -0600 |
| commit | 6166b0cda562dee46a5656d8c4641ee688c23421 (patch) | |
| tree | 8d5ba19dbed4ca920c9bc22a3dac6f1a244643b4 | |
| parent | e0c1c8bc5058cd3f8831b235c5963ab89840b33b (diff) | |
| download | rust-6166b0cda562dee46a5656d8c4641ee688c23421.tar.gz rust-6166b0cda562dee46a5656d8c4641ee688c23421.zip | |
Update core CloneToUninit tests
| -rw-r--r-- | library/core/tests/clone.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/library/core/tests/clone.rs b/library/core/tests/clone.rs index 71a328733b7..054b1d3d498 100644 --- a/library/core/tests/clone.rs +++ b/library/core/tests/clone.rs @@ -28,7 +28,7 @@ fn test_clone_to_uninit_slice_success() { let mut storage: MaybeUninit<[String; 3]> = MaybeUninit::uninit(); let b: [String; 3] = unsafe { - a[..].clone_to_uninit(storage.as_mut_ptr() as *mut [String]); + a[..].clone_to_uninit(storage.as_mut_ptr().cast()); storage.assume_init() }; @@ -70,7 +70,7 @@ fn test_clone_to_uninit_slice_drops_on_panic() { let mut storage: MaybeUninit<[CountsDropsAndPanics; 3]> = MaybeUninit::uninit(); // This should panic halfway through unsafe { - a[..].clone_to_uninit(storage.as_mut_ptr() as *mut [CountsDropsAndPanics]); + a[..].clone_to_uninit(storage.as_mut_ptr().cast()); } }) .unwrap_err(); @@ -89,13 +89,13 @@ fn test_clone_to_uninit_str() { let a = "hello"; let mut storage: MaybeUninit<[u8; 5]> = MaybeUninit::uninit(); - unsafe { a.clone_to_uninit(storage.as_mut_ptr() as *mut [u8] as *mut str) }; + unsafe { a.clone_to_uninit(storage.as_mut_ptr().cast()) }; assert_eq!(a.as_bytes(), unsafe { storage.assume_init() }.as_slice()); let mut b: Box<str> = "world".into(); assert_eq!(a.len(), b.len()); assert_ne!(a, &*b); - unsafe { a.clone_to_uninit(ptr::from_mut::<str>(&mut b)) }; + unsafe { a.clone_to_uninit(ptr::from_mut::<str>(&mut b).cast()) }; assert_eq!(a, &*b); } @@ -104,13 +104,13 @@ fn test_clone_to_uninit_cstr() { let a = c"hello"; let mut storage: MaybeUninit<[u8; 6]> = MaybeUninit::uninit(); - unsafe { a.clone_to_uninit(storage.as_mut_ptr() as *mut [u8] as *mut CStr) }; + unsafe { a.clone_to_uninit(storage.as_mut_ptr().cast()) }; assert_eq!(a.to_bytes_with_nul(), unsafe { storage.assume_init() }.as_slice()); let mut b: Box<CStr> = c"world".into(); assert_eq!(a.count_bytes(), b.count_bytes()); assert_ne!(a, &*b); - unsafe { a.clone_to_uninit(ptr::from_mut::<CStr>(&mut b)) }; + unsafe { a.clone_to_uninit(ptr::from_mut::<CStr>(&mut b).cast()) }; assert_eq!(a, &*b); } |
