-
Notifications
You must be signed in to change notification settings - Fork 13k
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
format_args
: insert implicit named arguments by format trait also
#109627
format_args
: insert implicit named arguments by format trait also
#109627
Conversation
This fixes rust-lang#109576 by not using the same argument for implicit named arguments that have the same name but different traits.
r? @lcnr (rustbot has picked a reviewer for you, use r? to override) |
hmmmm this isn't likely to have perf implications, but perhaps? @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 4f6a26f with merge e6706a8a21f2a7f85312351326ede56fca10b6de... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (e6706a8a21f2a7f85312351326ede56fca10b6de): comparison URL. Overall result: no relevant changes - no action neededBenchmarking 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. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis 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.
CyclesThis benchmark run did not return any relevant results for this metric. |
not familiar with this code r? @m-ou-se |
So, before this PR, this: format_args!("{x} {x:?}") expanded to: format_args!("{0} {0:?}", x) where But after this PR, it expands to: format_args!("{0} {1:?}", x, x) with each Currently, that results in roughly the same expression down the line, because the arguments are split/duplicated by format trait anyway, so two pointers to I'm wondering if there's another way to do that that doesn't duplicate the argument, without making the patch much more complicated. |
It could be possible, by changing the AST->HIR lowering step to use the individual span of implicit captured arguments instead. In AST we might have stored this already, and in HIR we just need to wire the span in expansion. |
I think I found a much easier way to fix this that also improves the diagnostics in some other cases. I'll post a PR shortly if it works. ^^ |
Now that github is finally back online, here is my alternative: #109664 |
This fixes #109576 by not using the same argument for implicit named arguments that have the same name but different traits.