Rollup merge of #141289 - compiler-errors:more-self, r=jhpratt
use `Self` alias in self types rather than manually substituting it Of the rougly 145 uses of `self: Ty` in the standard library, 5 of them don't use `Self` but instead choose to manually "substitute" the `impl`'s self type into the type. This leads to weird behavior sometimes (https://github.com/rust-lang/rust/issues/140611#issuecomment-2883761300) -- **to be clear**, none of these usages actually trigger any bugs, but it's possible that they may break in the future (or at least lead to lints), so let's just "fix" them proactively.
This commit is contained in:
@@ -1040,7 +1040,7 @@ impl OsStr {
|
||||
/// Converts a <code>[Box]<[OsStr]></code> into an [`OsString`] without copying or allocating.
|
||||
#[stable(feature = "into_boxed_os_str", since = "1.20.0")]
|
||||
#[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) };
|
||||
OsString { inner: Buf::from_box(boxed) }
|
||||
}
|
||||
|
||||
@@ -3163,7 +3163,7 @@ impl Path {
|
||||
/// allocating.
|
||||
#[stable(feature = "into_boxed_path", since = "1.20.0")]
|
||||
#[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 inner = unsafe { Box::from_raw(rw) };
|
||||
PathBuf { inner: OsString::from(inner) }
|
||||
|
||||
Reference in New Issue
Block a user