From 7ad3c5c4f8498f0683e1addc1b514c8e95ec7a48 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 19 Nov 2025 22:14:46 +0100 Subject: [PATCH] sgx: avoid unnecessarily creating a slice --- library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs b/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs index a60b83213fd96..fb410c2851604 100644 --- a/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs +++ b/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs @@ -143,12 +143,6 @@ unsafe impl UserSafe for [T] { align_of::() } - /// # Safety - /// Behavior is undefined if any of these conditions are violated: - /// * `ptr` must be [valid] for writes of `size` many bytes, and it must be - /// properly aligned. - /// - /// [valid]: core::ptr#safety /// # Panics /// /// This function panics if: @@ -158,8 +152,7 @@ unsafe impl UserSafe for [T] { let elem_size = size_of::(); assert_eq!(size % elem_size, 0); let len = size / elem_size; - // SAFETY: The caller must uphold the safety contract for `from_raw_sized_unchecked` - unsafe { slice::from_raw_parts_mut(ptr as _, len) } + ptr::slice_from_raw_parts_mut(ptr as _, len) } }