Skip to content

Commit e574ba4

Browse files
committed
Auto merge of #43477 - est31:master, r=alexcrichton
Switch to begin_panic again In #42938 we made the compiler emit a call to begin_panic_new in order to pass column info to it. Now with stage0 updated (#43320), we can safely change begin_panic and start emitting calls for it again.
2 parents 4a42ff4 + 90ac640 commit e574ba4

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

src/libstd/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ macro_rules! panic {
4646
panic!("explicit panic")
4747
});
4848
($msg:expr) => ({
49-
$crate::rt::begin_panic_new($msg, {
49+
$crate::rt::begin_panic($msg, {
5050
// static requires less code at runtime, more constant data
5151
static _FILE_LINE_COL: (&'static str, u32, u32) = (file!(), line!(), column!());
5252
&_FILE_LINE_COL

src/libstd/panicking.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ pub fn begin_panic_fmt(msg: &fmt::Arguments,
518518

519519
let mut s = String::new();
520520
let _ = s.write_fmt(*msg);
521-
begin_panic_new(s, file_line_col)
521+
begin_panic(s, file_line_col)
522522
}
523523

524524
// FIXME: In PR #42938, we have added the column as info passed to the panic
@@ -529,15 +529,17 @@ pub fn begin_panic_fmt(msg: &fmt::Arguments,
529529
// By changing the compiler source, we can only affect behaviour of higher
530530
// stages. We need to perform the switch over two stage0 replacements, using
531531
// a temporary function begin_panic_new while performing the switch:
532-
// 0. Right now, we tell stage1 onward to emit a call to begin_panic_new.
533-
// 1. In the first SNAP, stage0 calls begin_panic_new with the new ABI,
534-
// begin_panic stops being used. Now we can change begin_panic to
535-
// the new ABI, and start emitting calls to begin_panic in higher
532+
// 0. Before the current switch, we told stage1 onward to emit a call
533+
// to begin_panic_new.
534+
// 1. Right now, stage0 calls begin_panic_new with the new ABI,
535+
// begin_panic stops being used. We have changed begin_panic to
536+
// the new ABI, and started to emit calls to begin_panic in higher
536537
// stages again, this time with the new ABI.
537538
// 2. After the second SNAP, stage0 calls begin_panic with the new ABI,
538539
// and we can remove the temporary begin_panic_new function.
539540

540541
/// This is the entry point of panicking for panic!() and assert!().
542+
#[cfg(stage0)]
541543
#[unstable(feature = "libstd_sys_internals",
542544
reason = "used by the panic! macro",
543545
issue = "0")]
@@ -558,18 +560,15 @@ pub fn begin_panic_new<M: Any + Send>(msg: M, file_line_col: &(&'static str, u32
558560
reason = "used by the panic! macro",
559561
issue = "0")]
560562
#[inline(never)] #[cold] // avoid code bloat at the call sites as much as possible
561-
pub fn begin_panic<M: Any + Send>(msg: M, file_line: &(&'static str, u32)) -> ! {
563+
pub fn begin_panic<M: Any + Send>(msg: M, file_line_col: &(&'static str, u32, u32)) -> ! {
562564
// Note that this should be the only allocation performed in this code path.
563565
// Currently this means that panic!() on OOM will invoke this code path,
564566
// but then again we're not really ready for panic on OOM anyway. If
565567
// we do start doing this, then we should propagate this allocation to
566568
// be performed in the parent of this thread instead of the thread that's
567569
// panicking.
568570

569-
let (file, line) = *file_line;
570-
let file_line_col = (file, line, 0);
571-
572-
rust_panic_with_hook(Box::new(msg), &file_line_col)
571+
rust_panic_with_hook(Box::new(msg), file_line_col)
573572
}
574573

575574
/// Executes the primary logic for a panic, including checking for recursive

src/libstd/rt.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525

2626

2727
// Reexport some of our utilities which are expected by other crates.
28-
pub use panicking::{begin_panic_new, begin_panic, begin_panic_fmt, update_panic_count};
28+
#[cfg(stage0)]
29+
pub use panicking::begin_panic_new;
30+
pub use panicking::{begin_panic, begin_panic_fmt, update_panic_count};
2931

3032
#[cfg(not(test))]
3133
#[lang = "start"]

src/libsyntax/ext/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
774774
let expr_loc_ptr = self.expr_addr_of(span, expr_loc_tuple);
775775
self.expr_call_global(
776776
span,
777-
self.std_path(&["rt", "begin_panic_new"]),
777+
self.std_path(&["rt", "begin_panic"]),
778778
vec![
779779
self.expr_str(span, msg),
780780
expr_loc_ptr])

0 commit comments

Comments
 (0)