Skip to content

Provide a option for mask local filesystem info from panic messages #40492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/libcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ path = "../libcoretest/lib.rs"
[[bench]]
name = "corebenches"
path = "../libcore/benches/lib.rs"

[features]
mask_fileinfo_from_panic = []
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not as defaults.

11 changes: 8 additions & 3 deletions src/libcore/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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) }
}
}
1 change: 1 addition & 0 deletions src/libstd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ debug-jemalloc = ["alloc_jemalloc/debug"]
jemalloc = ["alloc_jemalloc"]
force_alloc_system = []
panic-unwind = ["panic_unwind"]
mask_fileinfo_from_panic = []
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not as defaults.

9 changes: 8 additions & 1 deletion src/libstd/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,16 @@ pub fn begin_panic<M: Any + Send>(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<Any + Send>,
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);

Expand Down