Skip to content

Commit d4fd798

Browse files
committed
Constify *const T::read[_unaligned] and *mut T::read[_unaligned]
1 parent 7594d2a commit d4fd798

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

library/core/src/ptr/const_ptr.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,9 @@ impl<T: ?Sized> *const T {
725725
///
726726
/// [`ptr::read`]: crate::ptr::read()
727727
#[stable(feature = "pointer_methods", since = "1.26.0")]
728+
#[rustc_const_unstable(feature = "const_ptr_read", issue = "none")]
728729
#[inline]
729-
pub unsafe fn read(self) -> T
730+
pub const unsafe fn read(self) -> T
730731
where
731732
T: Sized,
732733
{
@@ -763,8 +764,9 @@ impl<T: ?Sized> *const T {
763764
///
764765
/// [`ptr::read_unaligned`]: crate::ptr::read_unaligned()
765766
#[stable(feature = "pointer_methods", since = "1.26.0")]
767+
#[rustc_const_unstable(feature = "const_ptr_read", issue = "none")]
766768
#[inline]
767-
pub unsafe fn read_unaligned(self) -> T
769+
pub const unsafe fn read_unaligned(self) -> T
768770
where
769771
T: Sized,
770772
{

library/core/src/ptr/mut_ptr.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,9 @@ impl<T: ?Sized> *mut T {
832832
///
833833
/// [`ptr::read`]: crate::ptr::read()
834834
#[stable(feature = "pointer_methods", since = "1.26.0")]
835+
#[rustc_const_unstable(feature = "const_ptr_read", issue = "none")]
835836
#[inline]
836-
pub unsafe fn read(self) -> T
837+
pub const unsafe fn read(self) -> T
837838
where
838839
T: Sized,
839840
{
@@ -870,8 +871,9 @@ impl<T: ?Sized> *mut T {
870871
///
871872
/// [`ptr::read_unaligned`]: crate::ptr::read_unaligned()
872873
#[stable(feature = "pointer_methods", since = "1.26.0")]
874+
#[rustc_const_unstable(feature = "const_ptr_read", issue = "none")]
873875
#[inline]
874-
pub unsafe fn read_unaligned(self) -> T
876+
pub const unsafe fn read_unaligned(self) -> T
875877
where
876878
T: Sized,
877879
{

0 commit comments

Comments
 (0)