Skip to content

Commit b76a5be

Browse files
committed
Clean up comments in panicking infra.
1 parent 612c4c6 commit b76a5be

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/libstd/panicking.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
354354

355355
unsafe impl<'a> BoxMeUp for PanicPayload<'a> {
356356
fn take_box(&mut self) -> *mut (dyn Any + Send) {
357+
// We do two allocations here, unfortunately. But (a) they're required with the current
358+
// scheme, and (b) we don't handle panic + OOM properly anyway (see comment in
359+
// begin_panic below).
357360
let contents = mem::take(self.fill());
358361
Box::into_raw(Box::new(contents))
359362
}
@@ -363,11 +366,6 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
363366
}
364367
}
365368

366-
// We do two allocations here, unfortunately. But (a) they're
367-
// required with the current scheme, and (b) we don't handle
368-
// panic + OOM properly anyway (see comment in begin_panic
369-
// below).
370-
371369
let loc = info.location().unwrap(); // The current implementation always returns Some
372370
let msg = info.message().unwrap(); // The current implementation always returns Some
373371
rust_panic_with_hook(&mut PanicPayload::new(msg), info.message(), loc);
@@ -389,12 +387,6 @@ pub fn begin_panic<M: Any + Send>(msg: M, #[cfg(bootstrap)] _: &(&str, u32, u32)
389387
unsafe { intrinsics::abort() }
390388
}
391389

392-
// Note that this should be the only allocation performed in this code path.
393-
// Currently this means that panic!() on OOM will invoke this code path,
394-
// but then again we're not really ready for panic on OOM anyway. If
395-
// we do start doing this, then we should propagate this allocation to
396-
// be performed in the parent of this thread instead of the thread that's
397-
// panicking.
398390
rust_panic_with_hook(&mut PanicPayload::new(msg), None, Location::caller());
399391

400392
struct PanicPayload<A> {
@@ -409,6 +401,11 @@ pub fn begin_panic<M: Any + Send>(msg: M, #[cfg(bootstrap)] _: &(&str, u32, u32)
409401

410402
unsafe impl<A: Send + 'static> BoxMeUp for PanicPayload<A> {
411403
fn take_box(&mut self) -> *mut (dyn Any + Send) {
404+
// Note that this should be the only allocation performed in this code path. Currently
405+
// this means that panic!() on OOM will invoke this code path, but then again we're not
406+
// really ready for panic on OOM anyway. If we do start doing this, then we should
407+
// propagate this allocation to be performed in the parent of this thread instead of the
408+
// thread that's panicking.
412409
let data = match self.inner.take() {
413410
Some(a) => Box::new(a) as Box<dyn Any + Send>,
414411
None => process::abort(),

0 commit comments

Comments
 (0)