From 3a46cca4aeb2f5c0dcbc9e982d915c519c44f783 Mon Sep 17 00:00:00 2001 From: maekawatoshiki Date: Fri, 21 Aug 2020 14:14:58 +0900 Subject: Revert "`#![deny(unsafe_op_in_unsafe_fn)]` in sys/hermit" This reverts commit 7cae9e8c88e468e94c157d9aaee4b8e3cf90b9a4. --- library/std/src/sys/hermit/alloc.rs | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'library/std/src/sys/hermit/alloc.rs') diff --git a/library/std/src/sys/hermit/alloc.rs b/library/std/src/sys/hermit/alloc.rs index 04446172197..d153914e77e 100644 --- a/library/std/src/sys/hermit/alloc.rs +++ b/library/std/src/sys/hermit/alloc.rs @@ -1,5 +1,3 @@ -#![deny(unsafe_op_in_unsafe_fn)] - use crate::alloc::{GlobalAlloc, Layout, System}; use crate::ptr; use crate::sys::hermit::abi; @@ -8,33 +6,26 @@ use crate::sys::hermit::abi; unsafe impl GlobalAlloc for System { #[inline] unsafe fn alloc(&self, layout: Layout) -> *mut u8 { - // SAFETY: The safety contract for `malloc` must be upheld by the caller. - unsafe { abi::malloc(layout.size(), layout.align()) } + abi::malloc(layout.size(), layout.align()) } unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { - // SAFETY: The safety contract for `malloc` must be upheld by the caller. - // Also, `addr` must be valid for writes of `layout.size() * size_of::()` bytes. - unsafe { - let addr = abi::malloc(layout.size(), layout.align()); - - if !addr.is_null() { - ptr::write_bytes(addr, 0x00, layout.size()); - } + let addr = abi::malloc(layout.size(), layout.align()); - addr + if !addr.is_null() { + ptr::write_bytes(addr, 0x00, layout.size()); } + + addr } #[inline] unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { - // SAFETY: The safety contract for `free` must be upheld by the caller. - unsafe { abi::free(ptr, layout.size(), layout.align()) } + abi::free(ptr, layout.size(), layout.align()) } #[inline] unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { - // SAFETY: The safety contract for `realloc` must be upheld by the caller. - unsafe { abi::realloc(ptr, layout.size(), layout.align(), new_size) } + abi::realloc(ptr, layout.size(), layout.align(), new_size) } } -- cgit 1.4.1-3-g733a5