use Self alias in self types rather than manually substituting it

This commit is contained in:
Michael Goulet
2025-05-20 16:03:04 +02:00
parent b10555674f
commit 7b5ea0e7f5
4 changed files with 5 additions and 5 deletions

View File

@@ -234,7 +234,7 @@ impl str {
#[stable(feature = "str_box_extras", since = "1.20.0")] #[stable(feature = "str_box_extras", since = "1.20.0")]
#[must_use = "`self` will be dropped if the result is not used"] #[must_use = "`self` will be dropped if the result is not used"]
#[inline] #[inline]
pub fn into_boxed_bytes(self: Box<str>) -> Box<[u8]> { pub fn into_boxed_bytes(self: Box<Self>) -> Box<[u8]> {
self.into() self.into()
} }
@@ -501,7 +501,7 @@ impl str {
#[rustc_allow_incoherent_impl] #[rustc_allow_incoherent_impl]
#[must_use = "`self` will be dropped if the result is not used"] #[must_use = "`self` will be dropped if the result is not used"]
#[inline] #[inline]
pub fn into_string(self: Box<str>) -> String { pub fn into_string(self: Box<Self>) -> String {
let slice = Box::<[u8]>::from(self); let slice = Box::<[u8]>::from(self);
unsafe { String::from_utf8_unchecked(slice.into_vec()) } unsafe { String::from_utf8_unchecked(slice.into_vec()) }
} }

View File

@@ -1422,7 +1422,7 @@ impl<Ptr: DerefMut> Pin<Ptr> {
#[stable(feature = "pin_deref_mut", since = "1.84.0")] #[stable(feature = "pin_deref_mut", since = "1.84.0")]
#[must_use = "`self` will be dropped if the result is not used"] #[must_use = "`self` will be dropped if the result is not used"]
#[inline(always)] #[inline(always)]
pub fn as_deref_mut(self: Pin<&mut Pin<Ptr>>) -> Pin<&mut Ptr::Target> { pub fn as_deref_mut(self: Pin<&mut Self>) -> Pin<&mut Ptr::Target> {
// SAFETY: What we're asserting here is that going from // SAFETY: What we're asserting here is that going from
// //
// Pin<&mut Pin<Ptr>> // Pin<&mut Pin<Ptr>>

View File

@@ -1040,7 +1040,7 @@ impl OsStr {
/// Converts a <code>[Box]<[OsStr]></code> into an [`OsString`] without copying or allocating. /// Converts a <code>[Box]<[OsStr]></code> into an [`OsString`] without copying or allocating.
#[stable(feature = "into_boxed_os_str", since = "1.20.0")] #[stable(feature = "into_boxed_os_str", since = "1.20.0")]
#[must_use = "`self` will be dropped if the result is not used"] #[must_use = "`self` will be dropped if the result is not used"]
pub fn into_os_string(self: Box<OsStr>) -> OsString { pub fn into_os_string(self: Box<Self>) -> OsString {
let boxed = unsafe { Box::from_raw(Box::into_raw(self) as *mut Slice) }; let boxed = unsafe { Box::from_raw(Box::into_raw(self) as *mut Slice) };
OsString { inner: Buf::from_box(boxed) } OsString { inner: Buf::from_box(boxed) }
} }

View File

@@ -3163,7 +3163,7 @@ impl Path {
/// allocating. /// allocating.
#[stable(feature = "into_boxed_path", since = "1.20.0")] #[stable(feature = "into_boxed_path", since = "1.20.0")]
#[must_use = "`self` will be dropped if the result is not used"] #[must_use = "`self` will be dropped if the result is not used"]
pub fn into_path_buf(self: Box<Path>) -> PathBuf { pub fn into_path_buf(self: Box<Self>) -> PathBuf {
let rw = Box::into_raw(self) as *mut OsStr; let rw = Box::into_raw(self) as *mut OsStr;
let inner = unsafe { Box::from_raw(rw) }; let inner = unsafe { Box::from_raw(rw) };
PathBuf { inner: OsString::from(inner) } PathBuf { inner: OsString::from(inner) }