about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-01-04 23:52:44 +0530
committerGitHub <noreply@github.com>2020-01-04 23:52:44 +0530
commitcce055daef93bfa50b11b1d3368811fe586d8a42 (patch)
tree2adeeb04e178dd04953384d33a60f80ab58b6ef9 /src/libcore
parentcd8377d37e9bc47f9a5a982c41705a7800cbb51d (diff)
parent27b25eb822d32911b73991c7fd6921fea609f825 (diff)
downloadrust-cce055daef93bfa50b11b1d3368811fe586d8a42.tar.gz
rust-cce055daef93bfa50b11b1d3368811fe586d8a42.zip
Rollup merge of #67137 - anp:tracked-panic-internals, r=eddyb
libstd uses `core::panic::Location` where possible.

cc @eddyb
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/macros/mod.rs12
-rw-r--r--src/libcore/panicking.rs5
2 files changed, 6 insertions, 11 deletions
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]