about summary refs log tree commit diff
path: root/library/panic_unwind/src/lib.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-02-16 17:14:03 +0100
committerGitHub <noreply@github.com>2025-02-16 17:14:03 +0100
commit53b4c7c631544c6a156c30a7dfbdcfecbd846201 (patch)
treee9612b6f3076bf247b18fccf6027f22d656558d1 /library/panic_unwind/src/lib.rs
parent23032f31c91f2bb74ba4be20e075fcc929f66527 (diff)
parent28307554125f60440fcbf8076eee86f2ec1e4c1d (diff)
downloadrust-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/panic_unwind/src/lib.rs')
-rw-r--r--library/panic_unwind/src/lib.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/library/panic_unwind/src/lib.rs b/library/panic_unwind/src/lib.rs
index 45e2a466b4d..1111c2009b3 100644
--- a/library/panic_unwind/src/lib.rs
+++ b/library/panic_unwind/src/lib.rs
@@ -27,6 +27,7 @@
 #![allow(internal_features)]
 #![cfg_attr(not(bootstrap), feature(cfg_emscripten_wasm_eh))]
 #![warn(unreachable_pub)]
+#![deny(unsafe_op_in_unsafe_fn)]
 
 use alloc::boxed::Box;
 use core::any::Any;
@@ -87,14 +88,16 @@ unsafe extern "C" {
 #[rustc_std_internal_symbol]
 #[allow(improper_ctypes_definitions)]
 pub unsafe extern "C" fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static) {
-    Box::into_raw(imp::cleanup(payload))
+    unsafe { Box::into_raw(imp::cleanup(payload)) }
 }
 
 // Entry point for raising an exception, just delegates to the platform-specific
 // implementation.
 #[rustc_std_internal_symbol]
 pub unsafe fn __rust_start_panic(payload: &mut dyn PanicPayload) -> u32 {
-    let payload = Box::from_raw(payload.take_box());
+    unsafe {
+        let payload = Box::from_raw(payload.take_box());
 
-    imp::panic(payload)
+        imp::panic(payload)
+    }
 }