Skip to content

Commit fd72a52

Browse files
Urgaugitbot
authored and
gitbot
committed
panic_unwind: add #![warn(unreachable_pub)]
1 parent b0857ac commit fd72a52

File tree

7 files changed

+27
-26
lines changed

7 files changed

+27
-26
lines changed

panic_unwind/src/dummy.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use alloc::boxed::Box;
66
use core::any::Any;
77
use core::intrinsics;
88

9-
pub unsafe fn cleanup(_ptr: *mut u8) -> Box<dyn Any + Send> {
9+
pub(crate) unsafe fn cleanup(_ptr: *mut u8) -> Box<dyn Any + Send> {
1010
intrinsics::abort()
1111
}
1212

13-
pub unsafe fn panic(_data: Box<dyn Any + Send>) -> u32 {
13+
pub(crate) unsafe fn panic(_data: Box<dyn Any + Send>) -> u32 {
1414
intrinsics::abort()
1515
}

panic_unwind/src/emcc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct Exception {
6464
data: Option<Box<dyn Any + Send>>,
6565
}
6666

67-
pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
67+
pub(crate) unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
6868
// intrinsics::try actually gives us a pointer to this structure.
6969
#[repr(C)]
7070
struct CatchData {
@@ -93,7 +93,7 @@ pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
9393
out
9494
}
9595

96-
pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
96+
pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
9797
let exception = __cxa_allocate_exception(mem::size_of::<Exception>()) as *mut Exception;
9898
if exception.is_null() {
9999
return uw::_URC_FATAL_PHASE1_ERROR as u32;

panic_unwind/src/gcc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct Exception {
5858
cause: Box<dyn Any + Send>,
5959
}
6060

61-
pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
61+
pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
6262
let exception = Box::new(Exception {
6363
_uwe: uw::_Unwind_Exception {
6464
exception_class: RUST_EXCEPTION_CLASS,
@@ -82,7 +82,7 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
8282
}
8383
}
8484

85-
pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
85+
pub(crate) unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
8686
let exception = ptr as *mut uw::_Unwind_Exception;
8787
if (*exception).exception_class != RUST_EXCEPTION_CLASS {
8888
uw::_Unwind_DeleteException(exception);

panic_unwind/src/hermit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
use alloc::boxed::Box;
66
use core::any::Any;
77

8-
pub unsafe fn cleanup(_ptr: *mut u8) -> Box<dyn Any + Send> {
8+
pub(crate) unsafe fn cleanup(_ptr: *mut u8) -> Box<dyn Any + Send> {
99
extern "C" {
1010
pub fn __rust_abort() -> !;
1111
}
1212
__rust_abort();
1313
}
1414

15-
pub unsafe fn panic(_data: Box<dyn Any + Send>) -> u32 {
15+
pub(crate) unsafe fn panic(_data: Box<dyn Any + Send>) -> u32 {
1616
extern "C" {
1717
pub fn __rust_abort() -> !;
1818
}

panic_unwind/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#![cfg_attr(miri, allow(dead_code))]
2727
#![allow(internal_features)]
2828
#![cfg_attr(not(bootstrap), feature(cfg_emscripten_wasm_eh))]
29+
#![warn(unreachable_pub)]
2930

3031
use alloc::boxed::Box;
3132
use core::any::Any;

panic_unwind/src/miri.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ extern "Rust" {
1212
fn miri_start_unwind(payload: *mut u8) -> !;
1313
}
1414

15-
pub unsafe fn panic(payload: Box<dyn Any + Send>) -> u32 {
15+
pub(crate) unsafe fn panic(payload: Box<dyn Any + Send>) -> u32 {
1616
// The payload we pass to `miri_start_unwind` will be exactly the argument we get
1717
// in `cleanup` below. So we just box it up once, to get something pointer-sized.
1818
let payload_box: Payload = Box::new(payload);
1919
miri_start_unwind(Box::into_raw(payload_box) as *mut u8)
2020
}
2121

22-
pub unsafe fn cleanup(payload_box: *mut u8) -> Box<dyn Any + Send> {
22+
pub(crate) unsafe fn cleanup(payload_box: *mut u8) -> Box<dyn Any + Send> {
2323
// Recover the underlying `Box`.
2424
let payload_box: Payload = Box::from_raw(payload_box as *mut _);
2525
*payload_box

panic_unwind/src/seh.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,18 @@ struct Exception {
111111
mod imp {
112112
#[repr(transparent)]
113113
#[derive(Copy, Clone)]
114-
pub struct ptr_t(*mut u8);
114+
pub(super) struct ptr_t(*mut u8);
115115

116116
impl ptr_t {
117-
pub const fn null() -> Self {
117+
pub(super) const fn null() -> Self {
118118
Self(core::ptr::null_mut())
119119
}
120120

121-
pub const fn new(ptr: *mut u8) -> Self {
121+
pub(super) const fn new(ptr: *mut u8) -> Self {
122122
Self(ptr)
123123
}
124124

125-
pub const fn raw(self) -> *mut u8 {
125+
pub(super) const fn raw(self) -> *mut u8 {
126126
self.0
127127
}
128128
}
@@ -133,18 +133,18 @@ mod imp {
133133
// On 64-bit systems, SEH represents pointers as 32-bit offsets from `__ImageBase`.
134134
#[repr(transparent)]
135135
#[derive(Copy, Clone)]
136-
pub struct ptr_t(u32);
136+
pub(super) struct ptr_t(u32);
137137

138138
extern "C" {
139-
pub static __ImageBase: u8;
139+
static __ImageBase: u8;
140140
}
141141

142142
impl ptr_t {
143-
pub const fn null() -> Self {
143+
pub(super) const fn null() -> Self {
144144
Self(0)
145145
}
146146

147-
pub fn new(ptr: *mut u8) -> Self {
147+
pub(super) fn new(ptr: *mut u8) -> Self {
148148
// We need to expose the provenance of the pointer because it is not carried by
149149
// the `u32`, while the FFI needs to have this provenance to excess our statics.
150150
//
@@ -159,7 +159,7 @@ mod imp {
159159
Self(offset as u32)
160160
}
161161

162-
pub const fn raw(self) -> u32 {
162+
pub(super) const fn raw(self) -> u32 {
163163
self.0
164164
}
165165
}
@@ -168,21 +168,21 @@ mod imp {
168168
use imp::ptr_t;
169169

170170
#[repr(C)]
171-
pub struct _ThrowInfo {
171+
struct _ThrowInfo {
172172
pub attributes: c_uint,
173173
pub pmfnUnwind: ptr_t,
174174
pub pForwardCompat: ptr_t,
175175
pub pCatchableTypeArray: ptr_t,
176176
}
177177

178178
#[repr(C)]
179-
pub struct _CatchableTypeArray {
179+
struct _CatchableTypeArray {
180180
pub nCatchableTypes: c_int,
181181
pub arrayOfCatchableTypes: [ptr_t; 1],
182182
}
183183

184184
#[repr(C)]
185-
pub struct _CatchableType {
185+
struct _CatchableType {
186186
pub properties: c_uint,
187187
pub pType: ptr_t,
188188
pub thisDisplacement: _PMD,
@@ -191,14 +191,14 @@ pub struct _CatchableType {
191191
}
192192

193193
#[repr(C)]
194-
pub struct _PMD {
194+
struct _PMD {
195195
pub mdisp: c_int,
196196
pub pdisp: c_int,
197197
pub vdisp: c_int,
198198
}
199199

200200
#[repr(C)]
201-
pub struct _TypeDescriptor {
201+
struct _TypeDescriptor {
202202
pub pVFTable: *const u8,
203203
pub spare: *mut u8,
204204
pub name: [u8; 11],
@@ -288,7 +288,7 @@ cfg_if::cfg_if! {
288288
}
289289
}
290290

291-
pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
291+
pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
292292
use core::intrinsics::atomic_store_seqcst;
293293

294294
// _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 {
350350
_CxxThrowException(throw_ptr, (&raw mut THROW_INFO) as *mut _);
351351
}
352352

353-
pub unsafe fn cleanup(payload: *mut u8) -> Box<dyn Any + Send> {
353+
pub(crate) unsafe fn cleanup(payload: *mut u8) -> Box<dyn Any + Send> {
354354
// A null payload here means that we got here from the catch (...) of
355355
// __rust_try. This happens when a non-Rust foreign exception is caught.
356356
if payload.is_null() {

0 commit comments

Comments
 (0)