From 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:20:39 +0200 Subject: Merging upstream version 1.70.0+dfsg1. Signed-off-by: Daniel Baumann --- library/core/src/mem/maybe_uninit.rs | 16 ++++------------ library/core/src/mem/transmutability.rs | 4 ---- 2 files changed, 4 insertions(+), 16 deletions(-) (limited to 'library/core/src/mem') diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 3f4918365..9c6d48675 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -1241,13 +1241,9 @@ impl MaybeUninit { /// ``` #[unstable(feature = "maybe_uninit_as_bytes", issue = "93092")] pub fn slice_as_bytes(this: &[MaybeUninit]) -> &[MaybeUninit] { + let bytes = mem::size_of_val(this); // SAFETY: MaybeUninit is always valid, even for padding bytes - unsafe { - slice::from_raw_parts( - this.as_ptr() as *const MaybeUninit, - this.len() * mem::size_of::(), - ) - } + unsafe { slice::from_raw_parts(this.as_ptr() as *const MaybeUninit, bytes) } } /// Returns the contents of this mutable slice of `MaybeUninit` as a mutable slice of @@ -1274,13 +1270,9 @@ impl MaybeUninit { /// ``` #[unstable(feature = "maybe_uninit_as_bytes", issue = "93092")] pub fn slice_as_bytes_mut(this: &mut [MaybeUninit]) -> &mut [MaybeUninit] { + let bytes = mem::size_of_val(this); // SAFETY: MaybeUninit is always valid, even for padding bytes - unsafe { - slice::from_raw_parts_mut( - this.as_mut_ptr() as *mut MaybeUninit, - this.len() * mem::size_of::(), - ) - } + unsafe { slice::from_raw_parts_mut(this.as_mut_ptr() as *mut MaybeUninit, bytes) } } } diff --git a/library/core/src/mem/transmutability.rs b/library/core/src/mem/transmutability.rs index 3b98efff2..b53a330fa 100644 --- a/library/core/src/mem/transmutability.rs +++ b/library/core/src/mem/transmutability.rs @@ -5,10 +5,6 @@ /// notwithstanding whatever safety checks you have asked the compiler to [`Assume`] are satisfied. #[unstable(feature = "transmutability", issue = "99571")] #[lang = "transmute_trait"] -#[rustc_on_unimplemented( - message = "`{Src}` cannot be safely transmuted into `{Self}` in the defining scope of `{Context}`.", - label = "`{Src}` cannot be safely transmuted into `{Self}` in the defining scope of `{Context}`." -)] pub unsafe trait BikeshedIntrinsicFrom where Src: ?Sized, -- cgit v1.2.3