|
|
|
@@ -518,7 +518,7 @@ pub fn begin_panic_fmt(msg: &fmt::Arguments,
|
|
|
|
|
|
|
|
|
|
|
|
let mut s = String::new();
|
|
|
|
let mut s = String::new();
|
|
|
|
let _ = s.write_fmt(*msg);
|
|
|
|
let _ = s.write_fmt(*msg);
|
|
|
|
begin_panic_new(s, file_line_col)
|
|
|
|
begin_panic(s, file_line_col)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: In PR #42938, we have added the column as info passed to the panic
|
|
|
|
// 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,
|
|
|
|
// By changing the compiler source, we can only affect behaviour of higher
|
|
|
|
// By changing the compiler source, we can only affect behaviour of higher
|
|
|
|
// stages. We need to perform the switch over two stage0 replacements, using
|
|
|
|
// stages. We need to perform the switch over two stage0 replacements, using
|
|
|
|
// a temporary function begin_panic_new while performing the switch:
|
|
|
|
// a temporary function begin_panic_new while performing the switch:
|
|
|
|
// 0. Right now, we tell stage1 onward to emit a call to begin_panic_new.
|
|
|
|
// 0. Before the current switch, we told stage1 onward to emit a call
|
|
|
|
// 1. In the first SNAP, stage0 calls begin_panic_new with the new ABI,
|
|
|
|
// to begin_panic_new.
|
|
|
|
// begin_panic stops being used. Now we can change begin_panic to
|
|
|
|
// 1. Right now, stage0 calls begin_panic_new with the new ABI,
|
|
|
|
// the new ABI, and start emitting calls to begin_panic in higher
|
|
|
|
// begin_panic stops being used. We have changed begin_panic to
|
|
|
|
|
|
|
|
// the new ABI, and started to emit calls to begin_panic in higher
|
|
|
|
// stages again, this time with the new ABI.
|
|
|
|
// stages again, this time with the new ABI.
|
|
|
|
// 2. After the second SNAP, stage0 calls begin_panic with the new ABI,
|
|
|
|
// 2. After the second SNAP, stage0 calls begin_panic with the new ABI,
|
|
|
|
// and we can remove the temporary begin_panic_new function.
|
|
|
|
// and we can remove the temporary begin_panic_new function.
|
|
|
|
|
|
|
|
|
|
|
|
/// This is the entry point of panicking for panic!() and assert!().
|
|
|
|
/// This is the entry point of panicking for panic!() and assert!().
|
|
|
|
|
|
|
|
#[cfg(stage0)]
|
|
|
|
#[unstable(feature = "libstd_sys_internals",
|
|
|
|
#[unstable(feature = "libstd_sys_internals",
|
|
|
|
reason = "used by the panic! macro",
|
|
|
|
reason = "used by the panic! macro",
|
|
|
|
issue = "0")]
|
|
|
|
issue = "0")]
|
|
|
|
@@ -558,7 +560,7 @@ pub fn begin_panic_new<M: Any + Send>(msg: M, file_line_col: &(&'static str, u32
|
|
|
|
reason = "used by the panic! macro",
|
|
|
|
reason = "used by the panic! macro",
|
|
|
|
issue = "0")]
|
|
|
|
issue = "0")]
|
|
|
|
#[inline(never)] #[cold] // avoid code bloat at the call sites as much as possible
|
|
|
|
#[inline(never)] #[cold] // avoid code bloat at the call sites as much as possible
|
|
|
|
pub fn begin_panic<M: Any + Send>(msg: M, file_line: &(&'static str, u32)) -> ! {
|
|
|
|
pub fn begin_panic<M: Any + Send>(msg: M, file_line_col: &(&'static str, u32, u32)) -> ! {
|
|
|
|
// Note that this should be the only allocation performed in this code path.
|
|
|
|
// Note that this should be the only allocation performed in this code path.
|
|
|
|
// Currently this means that panic!() on OOM will invoke this code path,
|
|
|
|
// Currently this means that panic!() on OOM will invoke this code path,
|
|
|
|
// but then again we're not really ready for panic on OOM anyway. If
|
|
|
|
// but then again we're not really ready for panic on OOM anyway. If
|
|
|
|
@@ -566,10 +568,7 @@ pub fn begin_panic<M: Any + Send>(msg: M, file_line: &(&'static str, u32)) -> !
|
|
|
|
// be performed in the parent of this thread instead of the thread that's
|
|
|
|
// be performed in the parent of this thread instead of the thread that's
|
|
|
|
// panicking.
|
|
|
|
// panicking.
|
|
|
|
|
|
|
|
|
|
|
|
let (file, line) = *file_line;
|
|
|
|
rust_panic_with_hook(Box::new(msg), file_line_col)
|
|
|
|
let file_line_col = (file, line, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rust_panic_with_hook(Box::new(msg), &file_line_col)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Executes the primary logic for a panic, including checking for recursive
|
|
|
|
/// Executes the primary logic for a panic, including checking for recursive
|
|
|
|
|