diff options
| author | Urgau <urgau@numericable.fr> | 2024-12-13 18:58:15 +0100 |
|---|---|---|
| committer | Urgau <urgau@numericable.fr> | 2025-01-20 18:35:32 +0100 |
| commit | 477ef65121a8c22371ff5df7f9b07795c3518283 (patch) | |
| tree | 16ee6e6937e41da98e6c43f7bd3e2a9acd28b148 /library/panic_unwind | |
| parent | 6a64e3b89724395d87a394ed9ebd954c474b080a (diff) | |
| download | rust-477ef65121a8c22371ff5df7f9b07795c3518283.tar.gz rust-477ef65121a8c22371ff5df7f9b07795c3518283.zip | |
panic_unwind: add `#![warn(unreachable_pub)]`
Diffstat (limited to 'library/panic_unwind')
| -rw-r--r-- | library/panic_unwind/src/dummy.rs | 4 | ||||
| -rw-r--r-- | library/panic_unwind/src/emcc.rs | 4 | ||||
| -rw-r--r-- | library/panic_unwind/src/gcc.rs | 4 | ||||
| -rw-r--r-- | library/panic_unwind/src/hermit.rs | 4 | ||||
| -rw-r--r-- | library/panic_unwind/src/lib.rs | 1 | ||||
| -rw-r--r-- | library/panic_unwind/src/miri.rs | 4 | ||||
| -rw-r--r-- | library/panic_unwind/src/seh.rs | 32 |
7 files changed, 27 insertions, 26 deletions
diff --git a/library/panic_unwind/src/dummy.rs b/library/panic_unwind/src/dummy.rs index a4bcd216c60..a0d68766918 100644 --- a/library/panic_unwind/src/dummy.rs +++ b/library/panic_unwind/src/dummy.rs @@ -6,10 +6,10 @@ use alloc::boxed::Box; use core::any::Any; use core::intrinsics; -pub unsafe fn cleanup(_ptr: *mut u8) -> Box<dyn Any + Send> { +pub(crate) unsafe fn cleanup(_ptr: *mut u8) -> Box<dyn Any + Send> { intrinsics::abort() } -pub unsafe fn panic(_data: Box<dyn Any + Send>) -> u32 { +pub(crate) unsafe fn panic(_data: Box<dyn Any + Send>) -> u32 { intrinsics::abort() } diff --git a/library/panic_unwind/src/emcc.rs b/library/panic_unwind/src/emcc.rs index b986fc1c2a8..9127449edb1 100644 --- a/library/panic_unwind/src/emcc.rs +++ b/library/panic_unwind/src/emcc.rs @@ -64,7 +64,7 @@ struct Exception { data: Option<Box<dyn Any + Send>>, } -pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> { +pub(crate) unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> { // intrinsics::try actually gives us a pointer to this structure. #[repr(C)] struct CatchData { @@ -93,7 +93,7 @@ pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> { out } -pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 { +pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 { let exception = __cxa_allocate_exception(mem::size_of::<Exception>()) as *mut Exception; if exception.is_null() { return uw::_URC_FATAL_PHASE1_ERROR as u32; diff --git a/library/panic_unwind/src/gcc.rs b/library/panic_unwind/src/gcc.rs index b2389078afd..e478f6c5fc8 100644 --- a/library/panic_unwind/src/gcc.rs +++ b/library/panic_unwind/src/gcc.rs @@ -58,7 +58,7 @@ struct Exception { cause: Box<dyn Any + Send>, } -pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 { +pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 { let exception = Box::new(Exception { _uwe: uw::_Unwind_Exception { exception_class: RUST_EXCEPTION_CLASS, @@ -82,7 +82,7 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 { } } -pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> { +pub(crate) unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> { let exception = ptr as *mut uw::_Unwind_Exception; if (*exception).exception_class != RUST_EXCEPTION_CLASS { uw::_Unwind_DeleteException(exception); diff --git a/library/panic_unwind/src/hermit.rs b/library/panic_unwind/src/hermit.rs index 69b9edb77c5..8ac827dd9cc 100644 --- a/library/panic_unwind/src/hermit.rs +++ b/library/panic_unwind/src/hermit.rs @@ -5,14 +5,14 @@ use alloc::boxed::Box; use core::any::Any; -pub unsafe fn cleanup(_ptr: *mut u8) -> Box<dyn Any + Send> { +pub(crate) unsafe fn cleanup(_ptr: *mut u8) -> Box<dyn Any + Send> { extern "C" { pub fn __rust_abort() -> !; } __rust_abort(); } -pub unsafe fn panic(_data: Box<dyn Any + Send>) -> u32 { +pub(crate) unsafe fn panic(_data: Box<dyn Any + Send>) -> u32 { extern "C" { pub fn __rust_abort() -> !; } diff --git a/library/panic_unwind/src/lib.rs b/library/panic_unwind/src/lib.rs index dc78be76cb4..d6828164195 100644 --- a/library/panic_unwind/src/lib.rs +++ b/library/panic_unwind/src/lib.rs @@ -26,6 +26,7 @@ #![cfg_attr(miri, allow(dead_code))] #![allow(internal_features)] #![cfg_attr(not(bootstrap), feature(cfg_emscripten_wasm_eh))] +#![warn(unreachable_pub)] use alloc::boxed::Box; use core::any::Any; diff --git a/library/panic_unwind/src/miri.rs b/library/panic_unwind/src/miri.rs index 695adadd59b..a86f0e91eef 100644 --- a/library/panic_unwind/src/miri.rs +++ b/library/panic_unwind/src/miri.rs @@ -12,14 +12,14 @@ extern "Rust" { fn miri_start_unwind(payload: *mut u8) -> !; } -pub unsafe fn panic(payload: Box<dyn Any + Send>) -> u32 { +pub(crate) unsafe fn panic(payload: Box<dyn Any + Send>) -> u32 { // The payload we pass to `miri_start_unwind` will be exactly the argument we get // in `cleanup` below. So we just box it up once, to get something pointer-sized. let payload_box: Payload = Box::new(payload); miri_start_unwind(Box::into_raw(payload_box) as *mut u8) } -pub unsafe fn cleanup(payload_box: *mut u8) -> Box<dyn Any + Send> { +pub(crate) unsafe fn cleanup(payload_box: *mut u8) -> Box<dyn Any + Send> { // Recover the underlying `Box`. let payload_box: Payload = Box::from_raw(payload_box as *mut _); *payload_box diff --git a/library/panic_unwind/src/seh.rs b/library/panic_unwind/src/seh.rs index 5afa0a19756..21bfe74e1a2 100644 --- a/library/panic_unwind/src/seh.rs +++ b/library/panic_unwind/src/seh.rs @@ -111,18 +111,18 @@ struct Exception { mod imp { #[repr(transparent)] #[derive(Copy, Clone)] - pub struct ptr_t(*mut u8); + pub(super) struct ptr_t(*mut u8); impl ptr_t { - pub const fn null() -> Self { + pub(super) const fn null() -> Self { Self(core::ptr::null_mut()) } - pub const fn new(ptr: *mut u8) -> Self { + pub(super) const fn new(ptr: *mut u8) -> Self { Self(ptr) } - pub const fn raw(self) -> *mut u8 { + pub(super) const fn raw(self) -> *mut u8 { self.0 } } @@ -133,18 +133,18 @@ mod imp { // On 64-bit systems, SEH represents pointers as 32-bit offsets from `__ImageBase`. #[repr(transparent)] #[derive(Copy, Clone)] - pub struct ptr_t(u32); + pub(super) struct ptr_t(u32); extern "C" { - pub static __ImageBase: u8; + static __ImageBase: u8; } impl ptr_t { - pub const fn null() -> Self { + pub(super) const fn null() -> Self { Self(0) } - pub fn new(ptr: *mut u8) -> Self { + pub(super) fn new(ptr: *mut u8) -> Self { // We need to expose the provenance of the pointer because it is not carried by // the `u32`, while the FFI needs to have this provenance to excess our statics. // @@ -159,7 +159,7 @@ mod imp { Self(offset as u32) } - pub const fn raw(self) -> u32 { + pub(super) const fn raw(self) -> u32 { self.0 } } @@ -168,7 +168,7 @@ mod imp { use imp::ptr_t; #[repr(C)] -pub struct _ThrowInfo { +struct _ThrowInfo { pub attributes: c_uint, pub pmfnUnwind: ptr_t, pub pForwardCompat: ptr_t, @@ -176,13 +176,13 @@ pub struct _ThrowInfo { } #[repr(C)] -pub struct _CatchableTypeArray { +struct _CatchableTypeArray { pub nCatchableTypes: c_int, pub arrayOfCatchableTypes: [ptr_t; 1], } #[repr(C)] -pub struct _CatchableType { +struct _CatchableType { pub properties: c_uint, pub pType: ptr_t, pub thisDisplacement: _PMD, @@ -191,14 +191,14 @@ pub struct _CatchableType { } #[repr(C)] -pub struct _PMD { +struct _PMD { pub mdisp: c_int, pub pdisp: c_int, pub vdisp: c_int, } #[repr(C)] -pub struct _TypeDescriptor { +struct _TypeDescriptor { pub pVFTable: *const u8, pub spare: *mut u8, pub name: [u8; 11], @@ -288,7 +288,7 @@ cfg_if::cfg_if! { } } -pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 { +pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 { use core::intrinsics::atomic_store_seqcst; // _CxxThrowException executes entirely on this stack frame, so there's no @@ -350,7 +350,7 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 { _CxxThrowException(throw_ptr, (&raw mut THROW_INFO) as *mut _); } -pub unsafe fn cleanup(payload: *mut u8) -> Box<dyn Any + Send> { +pub(crate) unsafe fn cleanup(payload: *mut u8) -> Box<dyn Any + Send> { // A null payload here means that we got here from the catch (...) of // __rust_try. This happens when a non-Rust foreign exception is caught. if payload.is_null() { |
