-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Use str::to_owned
when format!
has no formatting arguments
#75894
Conversation
@bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit ad93d9ce8b08e2521c90a634967f7bb7c4726c76 with merge dd456fc07604958cdc0baa3a831659ecc61b2610... |
☀️ Try build successful - checks-actions, checks-azure |
Queued dd456fc07604958cdc0baa3a831659ecc61b2610 with parent 3cf8f69, future comparison URL. |
Finished benchmarking try commit (dd456fc07604958cdc0baa3a831659ecc61b2610): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
97f3e13
to
7dfbda9
Compare
str::to_owned
when format!
has no formating argumentsstr::to_owned
when format!
has no formatting arguments
str::to_owned
when format!
has no formatting argumentsstr::to_owned
when format!
has no formatting arguments
Codgen tests should be passed now. r? @nagisa for review or reassignment. |
8510a43
to
2c01a4e
Compare
230fcd6
to
00eefac
Compare
Thanks Ralf for pointing out my misconception about const fn. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The codegen tests seem sketchy to me for reasons outlined in the inline comments. It seems likely to be a kind of test that breaks on various medium-sized changes all the time. If the goal is to test that a function with just format!()
gets optimised (as a regression test for the referenced test) to an empty function, test exactly for that with
CHECK-LABEL: foo
CHECK-NEXT: ret
The "pretty"-print test seems to be sufficient if you're looking to ensure that things expand to what you expect, no need to bring codegen into an equation.
I don’t have strong opinions either way on the main change in this PR though. It mildly seems to me like it is optimizing a wrong thing in a wrong place, but I haven’t thought about it too much.
// inside `format_args!` itself. | ||
let r = match $crate::__export::format_args!($($arg)*) { | ||
// FIXME: We hope that constant propagation will make LLVM optimize out | ||
// this match. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this FIXME actionable at all? Is this really a FIXME?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is more like a HACK.
Thank you. I did it now. between the LABEL and the "ret void" there is a label. I have to account for it.
I want the codegen test to ensure the match is optimized out.
Yeah, it is a hack to me too. |
☔ The latest upstream changes (presumably #73996) made this pull request unmergeable. Please resolve the merge conflicts. |
LGTM, r=me once rebased. |
53a18b7
to
be1ea4b
Compare
Think about it more: it would be possible to write Anyway, we could open an issue to consider that possibility. @rustbot modify labels: -S-waiting-on-author +S-waiting-on-review |
@bors r+ |
📌 Commit be1ea4b has been approved by |
⌛ Testing commit be1ea4b with merge a1661d41bedb9d8c1b2b8a184440119170fd2a15... |
Your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
💔 Test failed - checks-actions |
More helpful log than rust-log-analyzer:
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
I got the LLVM-IR in #77285. Looks like the test is not reliable. Anyway, I don't think it is a right approach anymore. I'm going to close this PR if you all don't have objections. |
This fixes partially #75742 .
I would like to add must_use to
fmt::format
,String::from
andstr::into<String>
just like existing
must_use
onstr::to_owned
.A disadvantage of this PR is that it generates more code for debug builds. In release builds, the branch as_str is optimized out.