diff --git a/src/libcore/Cargo.toml b/src/libcore/Cargo.toml index e847c7fa3a0ec..d0c83498f1d4c 100644 --- a/src/libcore/Cargo.toml +++ b/src/libcore/Cargo.toml @@ -16,3 +16,6 @@ path = "../libcoretest/lib.rs" [[bench]] name = "corebenches" path = "../libcore/benches/lib.rs" + +[features] +mask_fileinfo_from_panic = [] \ No newline at end of file diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index 93ddfa72f63ca..5b3ab454024bd 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -28,7 +28,7 @@ //! one function. Currently, the actual symbol is declared in the standard //! library, but the location of this may change over time. -#![allow(dead_code, missing_docs)] +#![allow(dead_code, missing_docs, unused_variables)] #![unstable(feature = "core_panic", reason = "internal details of the implementation of the `panic!` \ and related macros", @@ -65,6 +65,11 @@ pub fn panic_fmt(fmt: fmt::Arguments, file_line: &(&'static str, u32)) -> ! { #[unwind] fn panic_impl(fmt: fmt::Arguments, file: &'static str, line: u32) -> !; } - let (file, line) = *file_line; - unsafe { panic_impl(fmt, file, line) } + + if cfg!(feature = "mask_fileinfo_from_panic") { + unsafe { panic_impl(fmt, "", 0) } + } else { + let (file, line) = *file_line; + unsafe { panic_impl(fmt, file, line) } + } } diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 46511452a7237..3cb61876fd3e6 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -39,3 +39,4 @@ debug-jemalloc = ["alloc_jemalloc/debug"] jemalloc = ["alloc_jemalloc"] force_alloc_system = [] panic-unwind = ["panic_unwind"] +mask_fileinfo_from_panic = [] \ No newline at end of file diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 3b5a1cffc7a22..a785400b186d8 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -519,9 +519,16 @@ pub fn begin_panic(msg: M, file_line: &(&'static str, u32)) -> ! /// run panic hooks, and then delegate to the actual implementation of panics. #[inline(never)] #[cold] +#[allow(unused_variables)] fn rust_panic_with_hook(msg: Box, file_line: &(&'static str, u32)) -> ! { - let (file, line) = *file_line; + let (file, line) = { + if cfg!(feature = "mask_fileinfo_from_panic") { + ("", 0) + } else { + *file_line + } + }; let panics = update_panic_count(1);