about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSky <sky@sky9.dev>2025-02-11 11:49:14 -0500
committerSky <sky@sky9.dev>2025-02-11 11:49:38 -0500
commit7bca1f2675d9f63b09ed9641e9aefe05b8ccc675 (patch)
tree5c17e5828fe147fd960169a2942ccdae5bad692f
parent8c61cd4df8434573190336b8f16169f3c2b22a7a (diff)
downloadrust-7bca1f2675d9f63b09ed9641e9aefe05b8ccc675.tar.gz
rust-7bca1f2675d9f63b09ed9641e9aefe05b8ccc675.zip
Fix missing const for inherent pointer `replace` methods
-rw-r--r--library/core/src/ptr/mut_ptr.rs3
-rw-r--r--library/core/src/ptr/non_null.rs3
2 files changed, 4 insertions, 2 deletions
diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs
index d1b0104c0fa..c102e21026c 100644
--- a/library/core/src/ptr/mut_ptr.rs
+++ b/library/core/src/ptr/mut_ptr.rs
@@ -1577,8 +1577,9 @@ impl<T: ?Sized> *mut T {
     ///
     /// [`ptr::replace`]: crate::ptr::replace()
     #[stable(feature = "pointer_methods", since = "1.26.0")]
+    #[rustc_const_stable(feature = "const_inherent_ptr_replace", since = "CURRENT_RUSTC_VERSION")]
     #[inline(always)]
-    pub unsafe fn replace(self, src: T) -> T
+    pub const unsafe fn replace(self, src: T) -> T
     where
         T: Sized,
     {
diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs
index d93069d384e..4c7f0817cf3 100644
--- a/library/core/src/ptr/non_null.rs
+++ b/library/core/src/ptr/non_null.rs
@@ -1169,7 +1169,8 @@ impl<T: ?Sized> NonNull<T> {
     /// [`ptr::replace`]: crate::ptr::replace()
     #[inline(always)]
     #[stable(feature = "non_null_convenience", since = "1.80.0")]
-    pub unsafe fn replace(self, src: T) -> T
+    #[rustc_const_stable(feature = "const_inherent_ptr_replace", since = "CURRENT_RUSTC_VERSION")]
+    pub const unsafe fn replace(self, src: T) -> T
     where
         T: Sized,
     {