Skip to content

Stabilize std::panic::Location::file_with_nul #145664

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Darksonn
Copy link
Contributor

@Darksonn Darksonn commented Aug 20, 2025

Closes: #141727

Nominating this for T-lang as per @traviscross #141727 (comment)

@Darksonn Darksonn added T-lang Relevant to the language team T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. I-lang-nominated Nominated for discussion during a lang team meeting. A-panic Area: Panicking machinery labels Aug 20, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 20, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 20, 2025
@traviscross traviscross added needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang and removed T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Aug 20, 2025
@traviscross
Copy link
Contributor

For context, we're making a language guarantee here about how the Rust compiler must work. After we accept this, it must null-terminate the file names it stores for source location information in the binary. This guarantee is being relied upon and exposed for the first time with the stabilization of Location::file_with_nul, so as with intrinsics, where we must approve the first exposure of the intrinsic on stable, we are here approving the first use of this new guarantee.

Given the benefits of this to interoperability, and the negligible cost of it, I propose that we do this.

@rfcbot fcp merge

We should find a place to document this guarantee in the Reference. @Darksonn, open to ideas and a PR here.

cc @rust-lang/lang-docs

@rfcbot
Copy link
Collaborator

rfcbot commented Aug 20, 2025

Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Aug 20, 2025
@traviscross traviscross added the S-waiting-on-documentation Status: Waiting on approved PRs to documentation before merging label Aug 20, 2025
@Darksonn Darksonn changed the title Stabilize file_with_nul Stabilize std::panic::Location::file_with_nul Aug 20, 2025
@VorpalBlade
Copy link

As a user report: I have a use for this API where I define tracepoints (USDT) for use with BPF tracing, dtrace etc:

In particular I want to trace tokio task spawns, polls etc, and tokio exposes a spawned_at() which returns a Location (this is far more useful than the tokio task ID for identifying what is going on).

As the trace point consumers (bpftrace, perf etc) expect C style strings, this would let me pass the file directly without a temporary allocation and copying. For tracepoints (that generally are expected to be minimal overhead) this is important.

@traviscross
Copy link
Contributor

As the trace point consumers (bpftrace, perf etc) expect C style strings, this would let me pass the file directly without a temporary allocation and copying. For tracepoints (that generally are expected to be minimal overhead) this is important.

That's actually a really great use case. Unlike the RfL use case we had considered, where they could in theory solve it for themselves by adjusting some kernel code, for the use case you mention there are fewer good options. Thanks for mentioning that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-panic Area: Panicking machinery disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. I-lang-nominated Nominated for discussion during a lang team meeting. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. S-waiting-on-documentation Status: Waiting on approved PRs to documentation before merging S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-lang Relevant to the language team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tracking Issue for NUL-terminated file names with #[track_caller]
6 participants