Skip to content

Tracking Issue for const_arguments_as_str #103900

New issue

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

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

Already on GitHub? # to your account

Closed
3 of 4 tasks
ghost opened this issue Nov 2, 2022 · 7 comments
Closed
3 of 4 tasks

Tracking Issue for const_arguments_as_str #103900

ghost opened this issue Nov 2, 2022 · 7 comments
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@ghost
Copy link

ghost commented Nov 2, 2022

Feature gate: #![feature(const_arguments_as_str)]

This is a tracking issue for const fmt::Arguments::as_str.
Note that the original PR didn't create a tracking issue.

Public API

// core::fmt

impl<'a> Arguments<'a> {
    #[stable(feature = "fmt_as_str", since = "1.52.0")]
    #[rustc_const_unstable(feature = "const_arguments_as_str", issue = "103900")]
    pub const fn as_str(&self) -> Option<&'static str>;
}

Steps / History

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

@ghost ghost added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Nov 2, 2022
JohnTitor pushed a commit to JohnTitor/rust that referenced this issue Nov 20, 2022
…-issue, r=the8472

Add tracking issue for `const_arguments_as_str`

Tracking issue: rust-lang#103900

The original PR didn't create a tracking issue.
@RalfJung
Copy link
Member

RalfJung commented Oct 7, 2024

The function list in the issue description is outdated, this feature gate now also includes

impl<'a> PanicMessage<'a> {
    pub const fn as_str(&self) -> Option<&'static str>;
}

(For some reason I can't edit the issue description...)

@rust-lang/libs-api Given that this has been regular-stable for a while, is there any reason not to make them const-stable as well? The implementations are trivial, and in fact they are already indirectly exposed on stable via the const panic machinery (specifically, it gets called in const_panic_fmt).

The main reason not to do this is that these functions cannot be actually called in const fn since you can't construct Arguments/PanicMessage in const context. But if that's the argument then IMO we should turn this into an internal feature gate that doesn't need a tracking issue (and PanicMessage::as_str can be fully de-constified).

@RalfJung RalfJung added the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Oct 7, 2024
@dtolnay
Copy link
Member

dtolnay commented Oct 7, 2024

these functions cannot be actually called in const fn since you can't construct Arguments/PanicMessage in const context.

This is usually not a compelling counterargument because const is still relevant for cases like:

const fn f(thing: Option<&Arguments>) {
    ...
    if let Some(thing) = thing {
        thing.as_str() ...
    }
    ...
}

and not having const on as_str can necessitate needlessly complicated workarounds.

@rust-lang/libs-api: this feature requires making the commitment that future designs of core::fmt::Arguments will not involve putting the string message from format_args!("...") behind a virtual function call, as in pub struct Arguments<'a> { repr: &'a dyn FmtRepr<'a> }.

@rfcbot fcp merge

@rfcbot
Copy link
Collaborator

rfcbot commented Oct 7, 2024

Team member @dtolnay 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!

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 Oct 7, 2024
@RalfJung
Copy link
Member

this feature requires making the commitment that future designs of core::fmt::Arguments will not involve putting the string message from format_args!("...") behind a virtual function call, as in pub struct Arguments<'a> { repr: &'a dyn FmtRepr<'a> }.

Or if we do add such an indirection then it has to be dyn const FmtRepr or so -- something like that could conceivably exist.

@rfcbot rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Oct 23, 2024
@rfcbot
Copy link
Collaborator

rfcbot commented Oct 23, 2024

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Oct 23, 2024
@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Nov 2, 2024
@rfcbot
Copy link
Collaborator

rfcbot commented Nov 2, 2024

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@RalfJung
Copy link
Member

RalfJung commented Nov 2, 2024

Stabilization PR is up: #132511

workingjubilee added a commit to workingjubilee/rustc that referenced this issue Nov 3, 2024
…=dtolnay

stabilize const_arguments_as_str

FCP passed in the [tracking issue](rust-lang#103900 (comment)).
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 3, 2024
…=dtolnay

stabilize const_arguments_as_str

FCP passed in the [tracking issue](rust-lang#103900 (comment)).
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 3, 2024
…=dtolnay

stabilize const_arguments_as_str

FCP passed in the [tracking issue](rust-lang#103900 (comment)).
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 3, 2024
Rollup merge of rust-lang#132511 - RalfJung:const_arguments_as_str, r=dtolnay

stabilize const_arguments_as_str

FCP passed in the [tracking issue](rust-lang#103900 (comment)).
@m-ou-se m-ou-se closed this as completed Nov 5, 2024
@m-ou-se m-ou-se removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Nov 5, 2024
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Nov 14, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants