From eaccda009f5891c67e554b31cfad4a52738f9b91 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Sat, 7 Dec 2019 08:37:08 -0800 Subject: core and std macros and panic internals use panic::Location::caller. --- src/libcore/macros/mod.rs | 12 +++--------- src/libcore/panicking.rs | 5 +++-- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'src/libcore') diff --git a/src/libcore/macros/mod.rs b/src/libcore/macros/mod.rs index 9a52823a454..0eb9e194236 100644 --- a/src/libcore/macros/mod.rs +++ b/src/libcore/macros/mod.rs @@ -1,19 +1,13 @@ #[doc(include = "panic.md")] #[macro_export] -#[allow_internal_unstable(core_panic, - // FIXME(anp, eddyb) `core_intrinsics` is used here to allow calling - // the `caller_location` intrinsic, but once `#[track_caller]` is implemented, - // `panicking::{panic, panic_fmt}` can use that instead of a `Location` argument. - core_intrinsics, - const_caller_location, -)] +#[allow_internal_unstable(core_panic, track_caller)] #[stable(feature = "core", since = "1.6.0")] macro_rules! panic { () => ( $crate::panic!("explicit panic") ); ($msg:expr) => ( - $crate::panicking::panic($msg, $crate::intrinsics::caller_location()) + $crate::panicking::panic($msg) ); ($msg:expr,) => ( $crate::panic!($msg) @@ -21,7 +15,7 @@ macro_rules! panic { ($fmt:expr, $($arg:tt)+) => ( $crate::panicking::panic_fmt( $crate::format_args!($fmt, $($arg)+), - $crate::intrinsics::caller_location(), + $crate::panic::Location::caller(), ) ); } diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index 7ebb72e3ce7..61b764f2d62 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -36,8 +36,9 @@ use crate::panic::{Location, PanicInfo}; // never inline unless panic_immediate_abort to avoid code // bloat at the call sites as much as possible #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] +#[track_caller] #[lang = "panic"] // needed by codegen for panic on overflow and other `Assert` MIR terminators -pub fn panic(expr: &str, location: &Location<'_>) -> ! { +pub fn panic(expr: &str) -> ! { if cfg!(feature = "panic_immediate_abort") { unsafe { super::intrinsics::abort() } } @@ -48,7 +49,7 @@ pub fn panic(expr: &str, location: &Location<'_>) -> ! { // truncation and padding (even though none is used here). Using // Arguments::new_v1 may allow the compiler to omit Formatter::pad from the // output binary, saving up to a few kilobytes. - panic_fmt(fmt::Arguments::new_v1(&[expr], &[]), location) + panic_fmt(fmt::Arguments::new_v1(&[expr], &[]), Location::caller()) } #[cold] -- cgit 1.4.1-3-g733a5