diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-28 04:53:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-28 04:53:06 +0100 |
| commit | 4728d66206c82c98aa4e1fad751e8aae7489c242 (patch) | |
| tree | a95e0d577f867d3fba9346478e13bcac3dc793a8 /src/libcore/panic.rs | |
| parent | c8eefdffe9480bbd84554eab3343f71f04af8f9a (diff) | |
| parent | 86e55b1882ac492d6234e5c5f97c7f151a11f5d2 (diff) | |
| download | rust-4728d66206c82c98aa4e1fad751e8aae7489c242.tar.gz rust-4728d66206c82c98aa4e1fad751e8aae7489c242.zip | |
Rollup merge of #65664 - anp:panic-location, r=eddyb
`std::panic::Location` is a lang_item, add `core::intrinsics::caller_location` (RFC 2091 3/N) [Tracking issue](https://github.com/rust-lang/rust/issues/47809) [RFC text](https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md) @eddyb suggested doing this intrinsic implementation ahead of actually implementing the `#[track_caller]` attribute so that there's an easily tested intermediate step between adding the shim and wiring up the attribute.
Diffstat (limited to 'src/libcore/panic.rs')
| -rw-r--r-- | src/libcore/panic.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/libcore/panic.rs b/src/libcore/panic.rs index 989fc96732a..51bbf3a8fd2 100644 --- a/src/libcore/panic.rs +++ b/src/libcore/panic.rs @@ -35,7 +35,7 @@ use crate::fmt; pub struct PanicInfo<'a> { payload: &'a (dyn Any + Send), message: Option<&'a fmt::Arguments<'a>>, - location: Location<'a>, + location: &'a Location<'a>, } impl<'a> PanicInfo<'a> { @@ -45,11 +45,16 @@ impl<'a> PanicInfo<'a> { issue = "0")] #[doc(hidden)] #[inline] - pub fn internal_constructor(message: Option<&'a fmt::Arguments<'a>>, - location: Location<'a>) - -> Self { + pub fn internal_constructor( + message: Option<&'a fmt::Arguments<'a>>, + location: &'a Location<'a>, + ) -> Self { struct NoPayload; - PanicInfo { payload: &NoPayload, location, message } + PanicInfo { + location, + message, + payload: &NoPayload, + } } #[doc(hidden)] @@ -162,6 +167,7 @@ impl fmt::Display for PanicInfo<'_> { /// /// panic!("Normal panic"); /// ``` +#[cfg_attr(not(bootstrap), lang = "panic_location")] #[derive(Debug)] #[stable(feature = "panic_hooks", since = "1.10.0")] pub struct Location<'a> { @@ -176,7 +182,7 @@ impl<'a> Location<'a> { and related macros", issue = "0")] #[doc(hidden)] - pub fn internal_constructor(file: &'a str, line: u32, col: u32) -> Self { + pub const fn internal_constructor(file: &'a str, line: u32, col: u32) -> Self { Location { file, line, col } } |
