From 37edd7f3d8b6e2db95b944e4ab887828530c1a23 Mon Sep 17 00:00:00 2001 From: Raekye Date: Fri, 15 Apr 2022 21:21:02 -0400 Subject: [PATCH] Change `as_uninit_*` methods on `NonNull` from taking `self` by reference to taking `self` by value. This is consistent with the methods of the same names on primitive pointers. The returned lifetime was already previously unbounded. --- core/src/ptr/non_null.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/ptr/non_null.rs b/core/src/ptr/non_null.rs index 6f402924e..2618cef36 100644 --- a/core/src/ptr/non_null.rs +++ b/core/src/ptr/non_null.rs @@ -124,7 +124,7 @@ impl NonNull { #[must_use] #[unstable(feature = "ptr_as_uninit", issue = "75402")] #[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")] - pub const unsafe fn as_uninit_ref<'a>(&self) -> &'a MaybeUninit { + pub const unsafe fn as_uninit_ref<'a>(self) -> &'a MaybeUninit { // SAFETY: the caller must guarantee that `self` meets all the // requirements for a reference. unsafe { &*self.cast().as_ptr() } @@ -158,7 +158,7 @@ impl NonNull { #[must_use] #[unstable(feature = "ptr_as_uninit", issue = "75402")] #[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")] - pub const unsafe fn as_uninit_mut<'a>(&mut self) -> &'a mut MaybeUninit { + pub const unsafe fn as_uninit_mut<'a>(self) -> &'a mut MaybeUninit { // SAFETY: the caller must guarantee that `self` meets all the // requirements for a reference. unsafe { &mut *self.cast().as_ptr() } @@ -592,7 +592,7 @@ impl NonNull<[T]> { #[must_use] #[unstable(feature = "ptr_as_uninit", issue = "75402")] #[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")] - pub const unsafe fn as_uninit_slice<'a>(&self) -> &'a [MaybeUninit] { + pub const unsafe fn as_uninit_slice<'a>(self) -> &'a [MaybeUninit] { // SAFETY: the caller must uphold the safety contract for `as_uninit_slice`. unsafe { slice::from_raw_parts(self.cast().as_ptr(), self.len()) } } @@ -655,7 +655,7 @@ impl NonNull<[T]> { #[must_use] #[unstable(feature = "ptr_as_uninit", issue = "75402")] #[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")] - pub const unsafe fn as_uninit_slice_mut<'a>(&self) -> &'a mut [MaybeUninit] { + pub const unsafe fn as_uninit_slice_mut<'a>(self) -> &'a mut [MaybeUninit] { // SAFETY: the caller must uphold the safety contract for `as_uninit_slice_mut`. unsafe { slice::from_raw_parts_mut(self.cast().as_ptr(), self.len()) } }