Rollup merge of #89920 - hudson-ayers:location-detail-control, r=davidtwco
Implement -Z location-detail flag This PR implements the `-Z location-detail` flag as described in https://github.com/rust-lang/rfcs/pull/2091 . `-Z location-detail=val` controls what location details are tracked when using `caller_location`. This allows users to control what location details are printed as part of panic messages, by allowing them to exclude any combination of filenames, line numbers, and column numbers. This option is intended to provide users with a way to mitigate the size impact of `#[track_caller]`. Some measurements of the savings of this approach on an embedded binary can be found here: https://github.com/rust-lang/rust/issues/70579#issuecomment-942556822 . Closes #70580 (unless people want to leave that open as a place for discussion of further improvements). This is my first real PR to rust, so any help correcting mistakes / understanding side effects / improving my tests is appreciated :) I have one question: RFC 2091 specified this as a debugging option (I think that is what -Z implies?). Does that mean this can never be stabilized without a separate MCP? If so, do I need to submit an MCP now, or is the initial RFC specifying this option sufficient for this to be merged as is, and then an MCP would be needed for eventual stabilization?
This commit is contained in:
commit
8fb194c86f
13 changed files with 135 additions and 6 deletions
|
@ -368,6 +368,8 @@ mod desc {
|
|||
"either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
|
||||
pub const parse_linker_plugin_lto: &str =
|
||||
"either a boolean (`yes`, `no`, `on`, `off`, etc), or the path to the linker plugin";
|
||||
pub const parse_location_detail: &str =
|
||||
"comma seperated list of location details to track: `file`, `line`, or `column`";
|
||||
pub const parse_switch_with_opt_path: &str =
|
||||
"an optional path to the profiling data output directory";
|
||||
pub const parse_merge_functions: &str = "one of: `disabled`, `trampolines`, or `aliases`";
|
||||
|
@ -484,6 +486,25 @@ mod parse {
|
|||
}
|
||||
}
|
||||
|
||||
crate fn parse_location_detail(ld: &mut LocationDetail, v: Option<&str>) -> bool {
|
||||
if let Some(v) = v {
|
||||
ld.line = false;
|
||||
ld.file = false;
|
||||
ld.column = false;
|
||||
for s in v.split(',') {
|
||||
match s {
|
||||
"file" => ld.file = true,
|
||||
"line" => ld.line = true,
|
||||
"column" => ld.column = true,
|
||||
_ => return false,
|
||||
}
|
||||
}
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
crate fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some(s) => {
|
||||
|
@ -1152,6 +1173,9 @@ options! {
|
|||
"a list LLVM plugins to enable (space separated)"),
|
||||
llvm_time_trace: bool = (false, parse_bool, [UNTRACKED],
|
||||
"generate JSON tracing data file from LLVM data (default: no)"),
|
||||
location_detail: LocationDetail = (LocationDetail::all(), parse_location_detail, [TRACKED],
|
||||
"comma seperated list of location details to be tracked when using caller_location \
|
||||
valid options are `file`, `line`, and `column` (default: all)"),
|
||||
ls: bool = (false, parse_bool, [UNTRACKED],
|
||||
"list the symbols defined by a library crate (default: no)"),
|
||||
macro_backtrace: bool = (false, parse_bool, [UNTRACKED],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue