diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2024-05-06 01:44:27 -0700 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2024-05-06 01:53:54 -0700 |
| commit | 61517dbbe6f1f41c935007fcdca5eba8be7477e2 (patch) | |
| tree | bbcadd803f973066e2ce1fc75ce4ab32fed35864 /library/core/src | |
| parent | d287f3e4eeaf680e8fe875f1ec75cca68f357d30 (diff) | |
Avoid a cast in `ptr::slice_from_raw_parts(_mut)`
Casting to `*const ()` or `*mut ()` just bloats the MIR, so let's not. If ACP#362 goes through we can keep calling `ptr::from_raw_parts(_mut)` in these also without the cast, but that hasn't had any libs-api attention yet, so I'm not waiting on it.
Diffstat (limited to 'library/core/src')
| -rw-r--r-- | library/core/src/ptr/mod.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index 5f3815859c8..8d7192c1b0f 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -812,7 +812,7 @@ pub const fn from_mut<T: ?Sized>(r: &mut T) -> *mut T { #[rustc_allow_const_fn_unstable(ptr_metadata)] #[rustc_diagnostic_item = "ptr_slice_from_raw_parts"] pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] { - from_raw_parts(data.cast(), len) + intrinsics::aggregate_raw_ptr(data, len) } /// Forms a raw mutable slice from a pointer and a length. @@ -858,7 +858,7 @@ pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] { #[rustc_const_unstable(feature = "const_slice_from_raw_parts_mut", issue = "67456")] #[rustc_diagnostic_item = "ptr_slice_from_raw_parts_mut"] pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] { - from_raw_parts_mut(data.cast(), len) + intrinsics::aggregate_raw_ptr(data, len) } /// Swaps the values at two mutable locations of the same type, without |
