diff options
| author | est31 <MTest31@outlook.com> | 2017-07-25 22:10:10 +0200 |
|---|---|---|
| committer | est31 <MTest31@outlook.com> | 2017-07-25 22:10:10 +0200 |
| commit | 90ac6408baa80fcd7fa28bc98af6046dba8c4bbb (patch) | |
| tree | 8a770ed8d696edd657aab041df0345b2b02d2d46 /src/libstd | |
| parent | c417ee9ae8c30ac307c58591da46cf62e91caac1 (diff) | |
| download | rust-90ac6408baa80fcd7fa28bc98af6046dba8c4bbb.tar.gz rust-90ac6408baa80fcd7fa28bc98af6046dba8c4bbb.zip | |
Switch to begin_panic again
In https://github.com/rust-lang/rust/pull/42938 we made the compiler emit a call to begin_panic_new in order to pass column info to it. Now with stage0 updated (https://github.com/rust-lang/rust/pull/43320), we can safely change begin_panic and start emitting calls for it again.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/macros.rs | 2 | ||||
| -rw-r--r-- | src/libstd/panicking.rs | 19 | ||||
| -rw-r--r-- | src/libstd/rt.rs | 4 |
3 files changed, 13 insertions, 12 deletions
diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 6ad22820a7d..44e8a23d353 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -46,7 +46,7 @@ macro_rules! panic { panic!("explicit panic") }); ($msg:expr) => ({ - $crate::rt::begin_panic_new($msg, { + $crate::rt::begin_panic($msg, { // static requires less code at runtime, more constant data static _FILE_LINE_COL: (&'static str, u32, u32) = (file!(), line!(), column!()); &_FILE_LINE_COL diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 494376b831e..04e1a579dec 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -518,7 +518,7 @@ pub fn begin_panic_fmt(msg: &fmt::Arguments, let mut s = String::new(); 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 @@ -529,15 +529,17 @@ pub fn begin_panic_fmt(msg: &fmt::Arguments, // By changing the compiler source, we can only affect behaviour of higher // stages. We need to perform the switch over two stage0 replacements, using // 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. -// 1. In the first SNAP, stage0 calls begin_panic_new with the new ABI, -// begin_panic stops being used. Now we can change begin_panic to -// the new ABI, and start emitting calls to begin_panic in higher +// 0. Before the current switch, we told stage1 onward to emit a call +// to begin_panic_new. +// 1. Right now, stage0 calls begin_panic_new with the new ABI, +// 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. // 2. After the second SNAP, stage0 calls begin_panic with the new ABI, // and we can remove the temporary begin_panic_new function. /// This is the entry point of panicking for panic!() and assert!(). +#[cfg(stage0)] #[unstable(feature = "libstd_sys_internals", reason = "used by the panic! macro", 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", issue = "0")] #[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. // 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 @@ -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 // panicking. - let (file, line) = *file_line; - let file_line_col = (file, line, 0); - - rust_panic_with_hook(Box::new(msg), &file_line_col) + rust_panic_with_hook(Box::new(msg), file_line_col) } /// Executes the primary logic for a panic, including checking for recursive diff --git a/src/libstd/rt.rs b/src/libstd/rt.rs index 2ee63527c14..2aa23ea043b 100644 --- a/src/libstd/rt.rs +++ b/src/libstd/rt.rs @@ -25,7 +25,9 @@ // Reexport some of our utilities which are expected by other crates. -pub use panicking::{begin_panic_new, begin_panic, begin_panic_fmt, update_panic_count}; +#[cfg(stage0)] +pub use panicking::begin_panic_new; +pub use panicking::{begin_panic, begin_panic_fmt, update_panic_count}; #[cfg(not(test))] #[lang = "start"] |
