about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2019-10-30 18:55:17 +0200
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2019-10-30 18:55:17 +0200
commit49f9626a553c0ff191aa96912f4880f99d0a8716 (patch)
tree76f612230c46613bdf13dedfa0a142729847301e
parentc17f89d6ede71cb0f8f0286307b1b83a642aff91 (diff)
downloadrust-49f9626a553c0ff191aa96912f4880f99d0a8716.tar.gz
rust-49f9626a553c0ff191aa96912f4880f99d0a8716.zip
caller_location: use in core::panic!.
-rw-r--r--src/libcore/macros.rs32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs
index 8ccd31c95d5..131fb52e2d2 100644
--- a/src/libcore/macros.rs
+++ b/src/libcore/macros.rs
@@ -26,31 +26,29 @@ macro_rules! panic {
 /// For details, see `std::macros`.
 #[cfg(not(bootstrap))]
 #[macro_export]
-#[allow_internal_unstable(core_panic, panic_internals)]
+#[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,
+)]
 #[stable(feature = "core", since = "1.6.0")]
 macro_rules! panic {
     () => (
         $crate::panic!("explicit panic")
     );
-    ($msg:expr) => ({
-        const LOC: &$crate::panic::Location<'_> = &$crate::panic::Location::internal_constructor(
-            $crate::file!(),
-            $crate::line!(),
-            $crate::column!(),
-        );
-        $crate::panicking::panic($msg, LOC)
-    });
+    ($msg:expr) => (
+        $crate::panicking::panic($msg, $crate::intrinsics::caller_location())
+    );
     ($msg:expr,) => (
         $crate::panic!($msg)
     );
-    ($fmt:expr, $($arg:tt)+) => ({
-        const LOC: &$crate::panic::Location<'_> = &$crate::panic::Location::internal_constructor(
-            $crate::file!(),
-            $crate::line!(),
-            $crate::column!(),
-        );
-        $crate::panicking::panic_fmt($crate::format_args!($fmt, $($arg)+), LOC)
-    });
+    ($fmt:expr, $($arg:tt)+) => (
+        $crate::panicking::panic_fmt(
+            $crate::format_args!($fmt, $($arg)+),
+            $crate::intrinsics::caller_location(),
+        )
+    );
 }
 
 /// Asserts that two expressions are equal to each other (using [`PartialEq`]).