-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Allow storing format_args!()
in variable
#140748
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
base: master
Are you sure you want to change the base?
Conversation
4971602
to
d261de6
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
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)
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (beb8d4e): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary 0.4%, secondary -0.2%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary 0.1%, secondary 2.4%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeResults (primary 0.1%, secondary 0.1%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 770.356s -> 770.437s (0.01%) |
format_args!()
in variable
@rfcbot reviewed Exciting! |
I'm @rfcbot reviewed |
I'm really happy we get to support this. Sounds like the extended lifetime behavior is straightforward and supported by all proposals for super let-like functionality. @rfcbot reviewed |
I was potentially worried about whether there's any specific details of @rfcbot reviewed |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
This uses `super let` to allow let f = format_args!("Hello {}", world); println!("{f}"); to work.
We no longer error in this case!
This message is no longer generated. This is probably a good thing. The relevant span is entirely in user code, and "format_args_nl" is an implementation detail with a name that isn't even public.
Diagnostics should know that the `&` for arguments in format_args!() come from the macro expansion rather than from the original source.
7742371
to
a1bd412
Compare
Fixes #92698
Tracking issue for super let: #139076
Tracking issue for format_args: #99012
This change allows:
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)