Allow storing format_args!() in variable or const#139135
Closed
m-ou-se wants to merge 6 commits intorust-lang:masterfrom
Closed
Allow storing format_args!() in variable or const#139135m-ou-se wants to merge 6 commits intorust-lang:masterfrom
m-ou-se wants to merge 6 commits intorust-lang:masterfrom
Conversation
This was referenced Mar 30, 2025
This comment was marked as outdated.
This comment was marked as outdated.
3b4d57d to
627b48c
Compare
This comment was marked as outdated.
This comment was marked as outdated.
627b48c to
25d0db8
Compare
This comment has been minimized.
This comment has been minimized.
25d0db8 to
2a4d503
Compare
This comment has been minimized.
This comment has been minimized.
2a4d503 to
44b1861
Compare
Member
Author
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 has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
Member
Author
|
I've opened a separate issue for the panic discussion: #139621 |
Collaborator
|
☔ The latest upstream changes (presumably #139632) made this pull request unmergeable. Please resolve the merge conflicts. |
3db7f57 to
a364c4b
Compare
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.
a364c4b to
3fbcdc0
Compare
This comment has been minimized.
This comment has been minimized.
Collaborator
|
☔ The latest upstream changes (presumably #139983) made this pull request unmergeable. Please resolve the merge conflicts. |
Member
Author
|
Closing this in favor of a slightly improved implementation without the |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
May 7, 2025
Allow storing format_args!() in variable Fixes rust-lang#92698 Tracking issue for super let: rust-lang#139076 This change allows: ```rust 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
Jun 19, 2025
Allow storing `format_args!()` in variable Fixes #92698 Tracking issue for super let: #139076 Tracking issue for format_args: #99012 This change allows: ```rust 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
Jun 20, 2025
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: ```rust 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
Jun 23, 2025
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: ```rust 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
Jun 26, 2025
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: ```rust 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
Jul 3, 2025
…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: ```rust 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)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #92698
Tracking issue for super let: #139076
This change allows:
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 anypanic!()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().)