Constify *const T::read[_unaligned] and *mut T::read[_unaligned]

This commit is contained in:
Albin Hedman 2020-12-26 01:25:33 +01:00
parent 7594d2a084
commit d4fd7987b5
2 changed files with 8 additions and 4 deletions

View File

@ -725,8 +725,9 @@ impl<T: ?Sized> *const T {
///
/// [`ptr::read`]: crate::ptr::read()
#[stable(feature = "pointer_methods", since = "1.26.0")]
#[rustc_const_unstable(feature = "const_ptr_read", issue = "none")]
#[inline]
pub unsafe fn read(self) -> T
pub const unsafe fn read(self) -> T
where
T: Sized,
{
@ -763,8 +764,9 @@ impl<T: ?Sized> *const T {
///
/// [`ptr::read_unaligned`]: crate::ptr::read_unaligned()
#[stable(feature = "pointer_methods", since = "1.26.0")]
#[rustc_const_unstable(feature = "const_ptr_read", issue = "none")]
#[inline]
pub unsafe fn read_unaligned(self) -> T
pub const unsafe fn read_unaligned(self) -> T
where
T: Sized,
{

View File

@ -832,8 +832,9 @@ impl<T: ?Sized> *mut T {
///
/// [`ptr::read`]: crate::ptr::read()
#[stable(feature = "pointer_methods", since = "1.26.0")]
#[rustc_const_unstable(feature = "const_ptr_read", issue = "none")]
#[inline]
pub unsafe fn read(self) -> T
pub const unsafe fn read(self) -> T
where
T: Sized,
{
@ -870,8 +871,9 @@ impl<T: ?Sized> *mut T {
///
/// [`ptr::read_unaligned`]: crate::ptr::read_unaligned()
#[stable(feature = "pointer_methods", since = "1.26.0")]
#[rustc_const_unstable(feature = "const_ptr_read", issue = "none")]
#[inline]
pub unsafe fn read_unaligned(self) -> T
pub const unsafe fn read_unaligned(self) -> T
where
T: Sized,
{