Skip to content

Implement -Z location-detail flag - #89920

Merged
bors merged 4 commits into
rust-lang:masterfrom
hudson-ayers:location-detail-control
Oct 23, 2021
Merged

Implement -Z location-detail flag#89920
bors merged 4 commits into
rust-lang:masterfrom
hudson-ayers:location-detail-control

Conversation

@hudson-ayers

Copy link
Copy Markdown
Contributor

This PR implements the -Z location-detail flag as described in rust-lang/rfcs#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: #70579 (comment) .

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?

@rust-highfive

Copy link
Copy Markdown
Contributor

Some changes occured to the CTFE / Miri engine

cc @rust-lang/miri

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @davidtwco

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 15, 2021
Comment threadcompiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs Outdated
@rust-log-analyzer

This comment has been minimized.

Comment threadcompiler/rustc_session/src/config.rs Outdated
@hudson-ayers
hudson-ayersforce-pushed the location-detail-control branch from 2d5b22d to 017d4d9CompareOctober 15, 2021 20:10
@rust-log-analyzer

This comment has been minimized.

@hudson-ayers
hudson-ayersforce-pushed the location-detail-control branch from 017d4d9 to 0f91d0dCompareOctober 15, 2021 21:44

@davidtwcodavidtwco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, r=me once these comments are resolved.

Comment threadsrc/doc/unstable-book/src/compiler-flags/location-detail.md Outdated
Comment threadcompiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs Outdated
@davidtwcodavidtwco added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 21, 2021
@hudson-ayers
hudson-ayersforce-pushed the location-detail-control branch from 0f91d0d to b802629CompareOctober 21, 2021 17:44
@hudson-ayers

Copy link
Copy Markdown
ContributorAuthor

I added a FIXME and implemented your other suggestion. Thanks for the review :)

@davidtwco

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Oct 21, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit b802629 has been approved by davidtwco

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 21, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 22, 2021
…l, r=davidtwco
Implement -Z location-detail flag
This PR implements the `-Z location-detail` flag as described in rust-lang/rfcs#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: rust-lang#70579 (comment) .
Closesrust-lang#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?
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 22, 2021
…l, r=davidtwco
Implement -Z location-detail flag
This PR implements the `-Z location-detail` flag as described in rust-lang/rfcs#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: rust-lang#70579 (comment) .
Closesrust-lang#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?
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 23, 2021
…askrgr
Rollup of 11 pull requests
Successful merges:
- rust-lang#83233 (Implement split_array and split_array_mut)
- rust-lang#88300 (Stabilise unix_process_wait_more, extra ExitStatusExt methods)
- rust-lang#89416 (nice_region_error: Include lifetime placeholders in error output)
- rust-lang#89468 (Report fatal lexer errors in `--cfg` command line arguments)
- rust-lang#89730 (add feature flag for `type_changing_struct_update`)
- rust-lang#89920 (Implement -Z location-detail flag)
- rust-lang#90070 (Add edition configuration to compiletest)
- rust-lang#90087 (Sync rustfmt subtree)
- rust-lang#90117 (Make RSplit<T, P>: Clone not require T: Clone)
- rust-lang#90122 (CI: make docker cache download and `docker load` time out after 10 minutes)
- rust-lang#90166 (Add comment documenting why we can't use a simpler solution)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 8fb194c into rust-lang:masterOct 23, 2021
@rustbotrustbot added this to the 1.58.0 milestone Oct 23, 2021
@korran

Copy link
Copy Markdown
Contributor

How do you use this flag to disable ALL the location details?

When I set -Z location-detail= (an empty comma-separated list), the compiler complains:

incorrect value `` for unstable option `location-detail` - comma separated list of location details to track: `file`, `line`, or `column` was expected

@hudson-ayers

Copy link
Copy Markdown
ContributorAuthor

I think I misunderstood how CLI option parsing works when implementing this, I thought passing an empty string to the option would pass Some("") to the parser, but that does not seem to be the case, so it is not possible to disable all the location details. I will followup with a fix and an additional test for this case soon

@hudson-ayers

Copy link
Copy Markdown
ContributorAuthor

#99620 contains the fix

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 31, 2022
…=davidtwco
`-Z location-detail`: provide option to disable all location details
As reported [here](rust-lang#89920 (comment)), when I first implemented the `-Z location-detail` flag there was a bug, where passing an empty list was not correctly supported, and instead rejected by the compiler. This PR fixes that such that passing an empty list results in no location details being tracked, as originally specified in rust-lang/rfcs#2091 .
This PR also adds a test case to verify that this option continues to work as intended.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mitigate binary size impact of implicit caller location

9 participants

@hudson-ayers@rust-highfive@rust-log-analyzer@davidtwco@bors@korran@fbstj@Aaron1011@rustbot