From 62cf2445633c03a927b7fef4abe82ea480df4078 Mon Sep 17 00:00:00 2001 From: Albin Hedman Date: Sat, 13 Mar 2021 19:45:48 +0100 Subject: [PATCH] Constify copy_to and copy_from --- library/core/src/ptr/const_ptr.rs | 6 ++++-- library/core/src/ptr/mut_ptr.rs | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 62ca07fc5a4..b511466acd6 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -819,9 +819,10 @@ pub unsafe fn read_volatile(self) -> T /// See [`ptr::copy`] for safety concerns and examples. /// /// [`ptr::copy`]: crate::ptr::copy() + #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] - pub unsafe fn copy_to(self, dest: *mut T, count: usize) + pub const unsafe fn copy_to(self, dest: *mut T, count: usize) where T: Sized, { @@ -837,9 +838,10 @@ pub unsafe fn copy_to(self, dest: *mut T, count: usize) /// See [`ptr::copy_nonoverlapping`] for safety concerns and examples. /// /// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping() + #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] - pub unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize) + pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize) where T: Sized, { diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index a365b66d8fc..fa09cf85435 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -926,9 +926,10 @@ pub unsafe fn read_volatile(self) -> T /// See [`ptr::copy`] for safety concerns and examples. /// /// [`ptr::copy`]: crate::ptr::copy() + #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] - pub unsafe fn copy_to(self, dest: *mut T, count: usize) + pub const unsafe fn copy_to(self, dest: *mut T, count: usize) where T: Sized, { @@ -944,9 +945,10 @@ pub unsafe fn copy_to(self, dest: *mut T, count: usize) /// See [`ptr::copy_nonoverlapping`] for safety concerns and examples. /// /// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping() + #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] - pub unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize) + pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize) where T: Sized, { @@ -962,9 +964,10 @@ pub unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize) /// See [`ptr::copy`] for safety concerns and examples. /// /// [`ptr::copy`]: crate::ptr::copy() + #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] - pub unsafe fn copy_from(self, src: *const T, count: usize) + pub const unsafe fn copy_from(self, src: *const T, count: usize) where T: Sized, { @@ -980,9 +983,10 @@ pub unsafe fn copy_from(self, src: *const T, count: usize) /// See [`ptr::copy_nonoverlapping`] for safety concerns and examples. /// /// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping() + #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")] #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] - pub unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize) + pub const unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize) where T: Sized, {