diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2025-02-16 17:14:03 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-16 17:14:03 +0100 |
| commit | 53b4c7c631544c6a156c30a7dfbdcfecbd846201 (patch) | |
| tree | e9612b6f3076bf247b18fccf6027f22d656558d1 /library/std/src | |
| parent | 23032f31c91f2bb74ba4be20e075fcc929f66527 (diff) | |
| parent | 28307554125f60440fcbf8076eee86f2ec1e4c1d (diff) | |
| download | rust-53b4c7c631544c6a156c30a7dfbdcfecbd846201.tar.gz rust-53b4c7c631544c6a156c30a7dfbdcfecbd846201.zip | |
Rollup merge of #136986 - ehuss:library-unsafe-fun, r=Noratrieb
Apply unsafe_op_in_unsafe_fn to the standard library This applies unsafe_op_in_unsafe_fn to the standard library in preparation for updating to Rust 2024. Closes https://github.com/rust-lang/rust/issues/127747 (I think?) cc ``@workingjubilee`` I have been testing a variety of targets, and I feel like they are all pretty much covered. I'll continue doing some testing async, but I don't expect to catch any more.
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/alloc.rs | 8 | ||||
| -rw-r--r-- | library/std/src/sys/pal/teeos/thread.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/pal/windows/stack_overflow_uwp.rs | 4 |
3 files changed, 7 insertions, 7 deletions
diff --git a/library/std/src/alloc.rs b/library/std/src/alloc.rs index 3936ed057e6..99d105a2454 100644 --- a/library/std/src/alloc.rs +++ b/library/std/src/alloc.rs @@ -20,11 +20,11 @@ //! //! unsafe impl GlobalAlloc for MyAllocator { //! unsafe fn alloc(&self, layout: Layout) -> *mut u8 { -//! System.alloc(layout) +//! unsafe { System.alloc(layout) } //! } //! //! unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { -//! System.dealloc(ptr, layout) +//! unsafe { System.dealloc(ptr, layout) } //! } //! } //! @@ -102,7 +102,7 @@ pub use alloc_crate::alloc::*; /// /// unsafe impl GlobalAlloc for Counter { /// unsafe fn alloc(&self, layout: Layout) -> *mut u8 { -/// let ret = System.alloc(layout); +/// let ret = unsafe { System.alloc(layout) }; /// if !ret.is_null() { /// ALLOCATED.fetch_add(layout.size(), Relaxed); /// } @@ -110,7 +110,7 @@ pub use alloc_crate::alloc::*; /// } /// /// unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { -/// System.dealloc(ptr, layout); +/// unsafe { System.dealloc(ptr, layout); } /// ALLOCATED.fetch_sub(layout.size(), Relaxed); /// } /// } diff --git a/library/std/src/sys/pal/teeos/thread.rs b/library/std/src/sys/pal/teeos/thread.rs index c779c5f3ed8..e3b4908f858 100644 --- a/library/std/src/sys/pal/teeos/thread.rs +++ b/library/std/src/sys/pal/teeos/thread.rs @@ -56,7 +56,7 @@ impl Thread { } }; - let ret = libc::pthread_create(&mut native, &attr, thread_start, p as *mut _); + let ret = unsafe { libc::pthread_create(&mut native, &attr, thread_start, p as *mut _) }; // Note: if the thread creation fails and this assert fails, then p will // be leaked. However, an alternative design could cause double-free // which is clearly worse. diff --git a/library/std/src/sys/pal/windows/stack_overflow_uwp.rs b/library/std/src/sys/pal/windows/stack_overflow_uwp.rs index 9e9b3efaf1b..6f1ea12fc1e 100644 --- a/library/std/src/sys/pal/windows/stack_overflow_uwp.rs +++ b/library/std/src/sys/pal/windows/stack_overflow_uwp.rs @@ -1,4 +1,4 @@ #![cfg_attr(test, allow(dead_code))] -pub unsafe fn reserve_stack() {} -pub unsafe fn init() {} +pub fn reserve_stack() {} +pub fn init() {} |
