caller_location: use in core::panic!.

This commit is contained in:
Eduard-Mihai Burtescu 2019-10-30 18:55:17 +02:00
parent c17f89d6ed
commit 49f9626a55

View File

@ -26,31 +26,29 @@ macro_rules! panic {
/// For details, see `std::macros`. /// For details, see `std::macros`.
#[cfg(not(bootstrap))] #[cfg(not(bootstrap))]
#[macro_export] #[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")] #[stable(feature = "core", since = "1.6.0")]
macro_rules! panic { macro_rules! panic {
() => ( () => (
$crate::panic!("explicit panic") $crate::panic!("explicit panic")
); );
($msg:expr) => ({ ($msg:expr) => (
const LOC: &$crate::panic::Location<'_> = &$crate::panic::Location::internal_constructor( $crate::panicking::panic($msg, $crate::intrinsics::caller_location())
$crate::file!(), );
$crate::line!(),
$crate::column!(),
);
$crate::panicking::panic($msg, LOC)
});
($msg:expr,) => ( ($msg:expr,) => (
$crate::panic!($msg) $crate::panic!($msg)
); );
($fmt:expr, $($arg:tt)+) => ({ ($fmt:expr, $($arg:tt)+) => (
const LOC: &$crate::panic::Location<'_> = &$crate::panic::Location::internal_constructor( $crate::panicking::panic_fmt(
$crate::file!(), $crate::format_args!($fmt, $($arg)+),
$crate::line!(), $crate::intrinsics::caller_location(),
$crate::column!(), )
); );
$crate::panicking::panic_fmt($crate::format_args!($fmt, $($arg)+), LOC)
});
} }
/// Asserts that two expressions are equal to each other (using [`PartialEq`]). /// Asserts that two expressions are equal to each other (using [`PartialEq`]).