Allow storing format_args!() in variable or const by m-ou-se · Pull Request #139135 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation25 Commits6 Checks6 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Fixes #92698
Tracking issue for super let: #139076
This change allows:
let name = "world"; let f = format_args!("hello {name}!");
println!("{f}");
This will need an FCP.
This accidentally 'fixes' a bunch of tests/ui/codegen/equal-pointers-unequal/* tests. Those tests seem very fragile and should probably not depend on formatting implementation details.
This accidentally 'fixes' tests/ui/consts/const-eval/format.rs: it now allows any panic!()
in a const fn. This might be expected. But we should then work on a better error when such a panic!() is const evaluated. (Now it reaches unreachable_unchecked().)
Status: Blocked on something else such as an RFC or other implementation work.
label
Area: The tidy tool
Status: Awaiting review from the assignee but also interested parties.
Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Relevant to the compiler team, which will review and decide on the PR/issue.
Relevant to the library team, which will review and decide on the PR/issue.
labels
This change is insta-stable, or significant enough to need a team FCP to proceed.
and removed T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Status: Awaiting review from the assignee but also interested parties.
Relevant to the library team, which will review and decide on the PR/issue.
Area: The tidy tool
labels
This was referenced
Mar 30, 2025
This comment was marked as outdated.
Area: The tidy tool
Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Relevant to the compiler team, which will review and decide on the PR/issue.
Relevant to the library team, which will review and decide on the PR/issue.
labels
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
The job
x86_64-gnu-tools
failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)FAILED TEST: tests/ui/manual_inspect.rs command: CLIPPY_CONF_DIR="tests" RUSTC_ICE="0" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/clippy-driver" [..]
One day, clippy will not break when I make any change to format_args!(). That day is not today.
This comment has been minimized.
This comment was marked as resolved.
I've opened a separate issue for the panic discussion: #139621
rustbot added the T-bootstrap
Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
label
This makes it posisble to do:
let f = format_args!("Hello, {name}!");
We can now just make new_v1_formatted an unsafe fn.
These tests rely on internal implementation details of format_args!(), which have changed now.
This comment has been minimized.
m-ou-se added T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
and removed T-bootstrap
Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Relevant to the library team, which will review and decide on the PR/issue.
labels
Closing this in favor of a slightly improved implementation without the const
issues discussed above: #140748
bors added a commit to rust-lang-ci/rust that referenced this pull request
Allow storing format_args!() in variable
Fixes rust-lang#92698
Tracking issue for super let: rust-lang#139076
This change allows:
let name = "world";
let f = format_args!("hello {name}!");
println!("{f}");
This will need an FCP.
This implementation makes use of super let
, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have a way of expressing temporary lifetimes like this, since the (stable) pin!()
macro needs this. (This was also the motivation for merging rust-lang#139114.)
[!NOTE] This PR causes many subtle changes in diagnostics output. Most of those are good. Some of those are bad. I've collected all the bad ones in the last commit. Those still need fixing. Marking this PR as draft.
(This is a second version of rust-lang#139135)
bors added a commit that referenced this pull request
Allow storing format_args!()
in variable
Fixes #92698
Tracking issue for super let: #139076
Tracking issue for format_args: #99012
This change allows:
let name = "world";
let f = format_args!("hello {name}!"); // New: Store format_args!() for later!
println!("{f}");
This will need an FCP.
This implementation makes use of super let
, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have a way of expressing temporary lifetimes like this, since the (stable) pin!()
macro needs this too. (This was also the motivation for merging #139114.)
(This is a second version of #139135)
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request
Allow storing format_args!()
in variable
Fixes rust-lang/rust#92698
Tracking issue for super let: rust-lang/rust#139076
Tracking issue for format_args: rust-lang/rust#99012
This change allows:
let name = "world";
let f = format_args!("hello {name}!"); // New: Store format_args!() for later!
println!("{f}");
This will need an FCP.
This implementation makes use of super let
, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have a way of expressing temporary lifetimes like this, since the (stable) pin!()
macro needs this too. (This was also the motivation for merging rust-lang/rust#139114.)
(This is a second version of rust-lang/rust#139135)
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request
Allow storing format_args!()
in variable
Fixes rust-lang/rust#92698
Tracking issue for super let: rust-lang/rust#139076
Tracking issue for format_args: rust-lang/rust#99012
This change allows:
let name = "world";
let f = format_args!("hello {name}!"); // New: Store format_args!() for later!
println!("{f}");
This will need an FCP.
This implementation makes use of super let
, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have a way of expressing temporary lifetimes like this, since the (stable) pin!()
macro needs this too. (This was also the motivation for merging rust-lang/rust#139114.)
(This is a second version of rust-lang/rust#139135)
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request
Allow storing format_args!()
in variable
Fixes rust-lang/rust#92698
Tracking issue for super let: rust-lang/rust#139076
Tracking issue for format_args: rust-lang/rust#99012
This change allows:
let name = "world";
let f = format_args!("hello {name}!"); // New: Store format_args!() for later!
println!("{f}");
This will need an FCP.
This implementation makes use of super let
, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have a way of expressing temporary lifetimes like this, since the (stable) pin!()
macro needs this too. (This was also the motivation for merging rust-lang/rust#139114.)
(This is a second version of rust-lang/rust#139135)
tautschnig pushed a commit to model-checking/verify-rust-std that referenced this pull request
…elmann
Allow storing format_args!()
in variable
Fixes rust-lang#92698
Tracking issue for super let: rust-lang#139076
Tracking issue for format_args: rust-lang#99012
This change allows:
let name = "world";
let f = format_args!("hello {name}!"); // New: Store format_args!() for later!
println!("{f}");
This will need an FCP.
This implementation makes use of super let
, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have a way of expressing temporary lifetimes like this, since the (stable) pin!()
macro needs this too. (This was also the motivation for merging rust-lang#139114.)
(This is a second version of rust-lang#139135)
Labels
This change is insta-stable, or significant enough to need a team FCP to proceed.
Status: Awaiting review from the assignee but also interested parties.
Relevant to the compiler team, which will review and decide on the PR/issue.
Relevant to the language team
Relevant to the library API team, which will review and decide on the PR/issue.