Skip to content

Commit 28cb203

Browse files
authored
Unrolled build for rust-lang#116008
Rollup merge of rust-lang#116008 - m-ou-se:boxmeup, r=oli-obk Rename BoxMeUp to PanicPayload. "BoxMeUp" is not very clear. Let's rename that to a description of what it actually represents: a panic payload. This PR also renames the structs that implement this trait to have more descriptive names. Part of rust-lang#116005 r? `@oli-obk`
2 parents 3223b0b + 76d9b36 commit 28cb203

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

library/core/src/panic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ pub macro unreachable_2021 {
9999
/// use.
100100
#[unstable(feature = "std_internals", issue = "none")]
101101
#[doc(hidden)]
102-
pub unsafe trait BoxMeUp {
102+
pub unsafe trait PanicPayload {
103103
/// Take full ownership of the contents.
104104
/// The return type is actually `Box<dyn Any + Send>`, but we cannot use `Box` in core.
105105
///
106106
/// After this method got called, only some dummy default value is left in `self`.
107107
/// Calling this method twice, or calling `get` after calling this method, is an error.
108108
///
109109
/// The argument is borrowed because the panic runtime (`__rust_start_panic`) only
110-
/// gets a borrowed `dyn BoxMeUp`.
110+
/// gets a borrowed `dyn PanicPayload`.
111111
fn take_box(&mut self) -> *mut (dyn Any + Send);
112112

113113
/// Just borrow the contents.

library/panic_abort/src/android.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use alloc::string::String;
22
use core::mem::transmute;
3-
use core::panic::BoxMeUp;
3+
use core::panic::PanicPayload;
44
use core::ptr::copy_nonoverlapping;
55

66
const ANDROID_SET_ABORT_MESSAGE: &[u8] = b"android_set_abort_message\0";
@@ -15,7 +15,7 @@ type SetAbortMessageType = unsafe extern "C" fn(*const libc::c_char) -> ();
1515
//
1616
// Weakly resolve the symbol for android_set_abort_message. This function is only available
1717
// for API >= 21.
18-
pub(crate) unsafe fn android_set_abort_message(payload: &mut dyn BoxMeUp) {
18+
pub(crate) unsafe fn android_set_abort_message(payload: &mut dyn PanicPayload) {
1919
let func_addr =
2020
libc::dlsym(libc::RTLD_DEFAULT, ANDROID_SET_ABORT_MESSAGE.as_ptr() as *const libc::c_char)
2121
as usize;

library/panic_abort/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
mod android;
2121

2222
use core::any::Any;
23-
use core::panic::BoxMeUp;
23+
use core::panic::PanicPayload;
2424

2525
#[rustc_std_internal_symbol]
2626
#[allow(improper_ctypes_definitions)]
@@ -30,7 +30,7 @@ pub unsafe extern "C" fn __rust_panic_cleanup(_: *mut u8) -> *mut (dyn Any + Sen
3030

3131
// "Leak" the payload and shim to the relevant abort on the platform in question.
3232
#[rustc_std_internal_symbol]
33-
pub unsafe fn __rust_start_panic(_payload: &mut dyn BoxMeUp) -> u32 {
33+
pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 {
3434
// Android has the ability to attach a message as part of the abort.
3535
#[cfg(target_os = "android")]
3636
android::android_set_abort_message(_payload);

library/panic_unwind/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
use alloc::boxed::Box;
3131
use core::any::Any;
32-
use core::panic::BoxMeUp;
32+
use core::panic::PanicPayload;
3333

3434
cfg_if::cfg_if! {
3535
if #[cfg(target_os = "emscripten")] {
@@ -99,7 +99,7 @@ pub unsafe extern "C" fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any
9999
// Entry point for raising an exception, just delegates to the platform-specific
100100
// implementation.
101101
#[rustc_std_internal_symbol]
102-
pub unsafe fn __rust_start_panic(payload: &mut dyn BoxMeUp) -> u32 {
102+
pub unsafe fn __rust_start_panic(payload: &mut dyn PanicPayload) -> u32 {
103103
let payload = Box::from_raw(payload.take_box());
104104

105105
imp::panic(payload)

library/std/src/panicking.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#![deny(unsafe_op_in_unsafe_fn)]
1111

1212
use crate::panic::BacktraceStyle;
13-
use core::panic::{BoxMeUp, Location, PanicInfo};
13+
use core::panic::{Location, PanicInfo, PanicPayload};
1414

1515
use crate::any::Any;
1616
use crate::fmt;
@@ -47,9 +47,9 @@ extern "C" {
4747
}
4848

4949
extern "Rust" {
50-
/// `BoxMeUp` lazily performs allocation only when needed (this avoids
50+
/// `PanicPayload` lazily performs allocation only when needed (this avoids
5151
/// allocations when using the "abort" panic runtime).
52-
fn __rust_start_panic(payload: &mut dyn BoxMeUp) -> u32;
52+
fn __rust_start_panic(payload: &mut dyn PanicPayload) -> u32;
5353
}
5454

5555
/// This function is called by the panic runtime if FFI code catches a Rust
@@ -543,14 +543,14 @@ pub fn panicking() -> bool {
543543
#[cfg(not(test))]
544544
#[panic_handler]
545545
pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
546-
struct PanicPayload<'a> {
546+
struct FormatStringPayload<'a> {
547547
inner: &'a fmt::Arguments<'a>,
548548
string: Option<String>,
549549
}
550550

551-
impl<'a> PanicPayload<'a> {
552-
fn new(inner: &'a fmt::Arguments<'a>) -> PanicPayload<'a> {
553-
PanicPayload { inner, string: None }
551+
impl<'a> FormatStringPayload<'a> {
552+
fn new(inner: &'a fmt::Arguments<'a>) -> Self {
553+
Self { inner, string: None }
554554
}
555555

556556
fn fill(&mut self) -> &mut String {
@@ -566,7 +566,7 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
566566
}
567567
}
568568

569-
unsafe impl<'a> BoxMeUp for PanicPayload<'a> {
569+
unsafe impl<'a> PanicPayload for FormatStringPayload<'a> {
570570
fn take_box(&mut self) -> *mut (dyn Any + Send) {
571571
// We do two allocations here, unfortunately. But (a) they're required with the current
572572
// scheme, and (b) we don't handle panic + OOM properly anyway (see comment in
@@ -580,9 +580,9 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
580580
}
581581
}
582582

583-
struct StrPanicPayload(&'static str);
583+
struct StaticStrPayload(&'static str);
584584

585-
unsafe impl BoxMeUp for StrPanicPayload {
585+
unsafe impl PanicPayload for StaticStrPayload {
586586
fn take_box(&mut self) -> *mut (dyn Any + Send) {
587587
Box::into_raw(Box::new(self.0))
588588
}
@@ -599,15 +599,15 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
599599
// `rust_panic_with_hook` construct a new `PanicInfo`?
600600
if let Some(msg) = msg.as_str() {
601601
rust_panic_with_hook(
602-
&mut StrPanicPayload(msg),
602+
&mut StaticStrPayload(msg),
603603
info.message(),
604604
loc,
605605
info.can_unwind(),
606606
info.force_no_backtrace(),
607607
);
608608
} else {
609609
rust_panic_with_hook(
610-
&mut PanicPayload::new(msg),
610+
&mut FormatStringPayload::new(msg),
611611
info.message(),
612612
loc,
613613
info.can_unwind(),
@@ -637,25 +637,25 @@ pub const fn begin_panic<M: Any + Send>(msg: M) -> ! {
637637
let loc = Location::caller();
638638
return crate::sys_common::backtrace::__rust_end_short_backtrace(move || {
639639
rust_panic_with_hook(
640-
&mut PanicPayload::new(msg),
640+
&mut Payload::new(msg),
641641
None,
642642
loc,
643643
/* can_unwind */ true,
644644
/* force_no_backtrace */ false,
645645
)
646646
});
647647

648-
struct PanicPayload<A> {
648+
struct Payload<A> {
649649
inner: Option<A>,
650650
}
651651

652-
impl<A: Send + 'static> PanicPayload<A> {
653-
fn new(inner: A) -> PanicPayload<A> {
654-
PanicPayload { inner: Some(inner) }
652+
impl<A: Send + 'static> Payload<A> {
653+
fn new(inner: A) -> Payload<A> {
654+
Payload { inner: Some(inner) }
655655
}
656656
}
657657

658-
unsafe impl<A: Send + 'static> BoxMeUp for PanicPayload<A> {
658+
unsafe impl<A: Send + 'static> PanicPayload for Payload<A> {
659659
fn take_box(&mut self) -> *mut (dyn Any + Send) {
660660
// Note that this should be the only allocation performed in this code path. Currently
661661
// this means that panic!() on OOM will invoke this code path, but then again we're not
@@ -684,7 +684,7 @@ pub const fn begin_panic<M: Any + Send>(msg: M) -> ! {
684684
/// panics, panic hooks, and finally dispatching to the panic runtime to either
685685
/// abort or unwind.
686686
fn rust_panic_with_hook(
687-
payload: &mut dyn BoxMeUp,
687+
payload: &mut dyn PanicPayload,
688688
message: Option<&fmt::Arguments<'_>>,
689689
location: &Location<'_>,
690690
can_unwind: bool,
@@ -760,7 +760,7 @@ pub fn rust_panic_without_hook(payload: Box<dyn Any + Send>) -> ! {
760760

761761
struct RewrapBox(Box<dyn Any + Send>);
762762

763-
unsafe impl BoxMeUp for RewrapBox {
763+
unsafe impl PanicPayload for RewrapBox {
764764
fn take_box(&mut self) -> *mut (dyn Any + Send) {
765765
Box::into_raw(mem::replace(&mut self.0, Box::new(())))
766766
}
@@ -777,7 +777,7 @@ pub fn rust_panic_without_hook(payload: Box<dyn Any + Send>) -> ! {
777777
/// yer breakpoints.
778778
#[inline(never)]
779779
#[cfg_attr(not(test), rustc_std_internal_symbol)]
780-
fn rust_panic(msg: &mut dyn BoxMeUp) -> ! {
780+
fn rust_panic(msg: &mut dyn PanicPayload) -> ! {
781781
let code = unsafe { __rust_start_panic(msg) };
782782
rtabort!("failed to initiate panic, error {code}")
783783
}

0 commit comments

Comments
 (0)