Skip to content

Commit

Permalink
Sparkle some attributes over CloneToUninit stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
GrigorenkoPV committed Jun 25, 2024
1 parent 489dcc7 commit aadd353
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions library/core/src/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ unsafe impl<T: Clone> CloneToUninit for T {

// Specialized implementation for types that are [`Copy`], not just [`Clone`],
// and can therefore be copied bitwise.
#[doc(hidden)]
#[unstable(feature = "clone_to_uninit", issue = "126799")]
unsafe impl<T: Copy> CloneToUninit for T {
unsafe fn clone_to_uninit(&self, dst: *mut Self) {
Expand All @@ -296,6 +297,7 @@ unsafe impl<T: Copy> CloneToUninit for T {
#[unstable(feature = "clone_to_uninit", issue = "126799")]
unsafe impl<T: Clone> CloneToUninit for [T] {
#[cfg_attr(debug_assertions, track_caller)]
#[inline]
default unsafe fn clone_to_uninit(&self, dst: *mut Self) {
let len = self.len();
// This is the most likely mistake to make, so check it as a debug assertion.
Expand Down Expand Up @@ -323,9 +325,11 @@ unsafe impl<T: Clone> CloneToUninit for [T] {
}
}

#[doc(hidden)]
#[unstable(feature = "clone_to_uninit", issue = "126799")]
unsafe impl<T: Copy> CloneToUninit for [T] {
#[cfg_attr(debug_assertions, track_caller)]
#[inline]
unsafe fn clone_to_uninit(&self, dst: *mut Self) {
let len = self.len();
// This is the most likely mistake to make, so check it as a debug assertion.
Expand All @@ -346,6 +350,7 @@ unsafe impl<T: Copy> CloneToUninit for [T] {
#[unstable(feature = "clone_to_uninit", issue = "126799")]
unsafe impl CloneToUninit for str {
#[cfg_attr(debug_assertions, track_caller)]
#[inline]
unsafe fn clone_to_uninit(&self, dst: *mut Self) {
// SAFETY: str is just a [u8] with UTF-8 invariant
unsafe { self.as_bytes().clone_to_uninit(dst as *mut [u8]) }
Expand Down
1 change: 1 addition & 0 deletions library/std/src/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,7 @@ impl Clone for Box<OsStr> {
#[unstable(feature = "clone_to_uninit", issue = "126799")]
unsafe impl CloneToUninit for OsStr {
#[cfg_attr(debug_assertions, track_caller)]
#[inline]
unsafe fn clone_to_uninit(&self, dst: *mut Self) {
// SAFETY: we're just a wrapper around a platform-specific Slice
unsafe { self.inner.clone_to_uninit(addr_of_mut!((*dst).inner)) }
Expand Down
1 change: 1 addition & 0 deletions library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3032,6 +3032,7 @@ impl Path {
#[unstable(feature = "clone_to_uninit", issue = "126799")]
unsafe impl CloneToUninit for Path {
#[cfg_attr(debug_assertions, track_caller)]
#[inline]
unsafe fn clone_to_uninit(&self, dst: *mut Self) {
// SAFETY: Path is just a wrapper around OsStr
unsafe { self.inner.clone_to_uninit(core::ptr::addr_of_mut!((*dst).inner)) }
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/os_str/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ impl Slice {
#[unstable(feature = "clone_to_uninit", issue = "126799")]
unsafe impl CloneToUninit for Slice {
#[cfg_attr(debug_assertions, track_caller)]
#[inline]
unsafe fn clone_to_uninit(&self, dst: *mut Self) {
// SAFETY: we're just a wrapper around [u8]
unsafe { self.inner.clone_to_uninit(addr_of_mut!((*dst).inner)) }
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/os_str/wtf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ impl Slice {
#[unstable(feature = "clone_to_uninit", issue = "126799")]
unsafe impl CloneToUninit for Slice {
#[cfg_attr(debug_assertions, track_caller)]
#[inline]
unsafe fn clone_to_uninit(&self, dst: *mut Self) {
// SAFETY: we're just a wrapper around Wtf8
unsafe { self.inner.clone_to_uninit(addr_of_mut!((*dst).inner)) }
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys_common/wtf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,7 @@ impl Hash for Wtf8 {
#[unstable(feature = "clone_to_uninit", issue = "126799")]
unsafe impl CloneToUninit for Wtf8 {
#[cfg_attr(debug_assertions, track_caller)]
#[inline]
unsafe fn clone_to_uninit(&self, dst: *mut Self) {
// SAFETY: we're just a wrapper around [u8]
unsafe { self.bytes.clone_to_uninit(addr_of_mut!((*dst).bytes)) }
Expand Down

0 comments on commit aadd353

Please # to comment.