-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Fix invalid special casing of the unreachable! macro #93179
Conversation
r? @oli-obk (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 7331ddeed4310ba606bae8479850985251a35dd3 with merge 07d94fb27d02adc112536d7c6439de6a373f2e03... |
cc discussion about implementation strategy: #92137 (comment) |
cc @m-ou-se |
☀️ Try build successful - checks-actions |
Queued 07d94fb27d02adc112536d7c6439de6a373f2e03 with parent 17d29dc, future comparison URL. |
Finished benchmarking commit (07d94fb27d02adc112536d7c6439de6a373f2e03): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking 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 led to changes in compiler perf. @bors rollup=never |
Thanks for working on this! I'll try to review this soon. I'll have to note that for any edition-specific changes, we also need to add a migration lint to automatically upgrade code from older editions. (Just like we already have for
Another option is to make that work using a nested format_args: - $crate::panic!($crate::concat!("internal error: entered unreachable code: ", $fmt), $($arg)*)
+ $crate::panic!("internal error: entered unreachable code: {}", $crate::format_args!($fmt, $($arg)*)) (Edit: In general I try to avoid using (Edit 2: I've started a discussion on optimizing nested format_args on Zulip.) |
I'd be happy to extend the |
I've updated the implementation to use a nested
I tried to expand the current |
@@ -0,0 +1,14 @@ | |||
// ignore-emscripten no processes |
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.
Why are you ignoring emscripten in these tests?
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.
I did the same as this test unreachable-fmt-msg.rs
Maybe you could make the second case of |
|
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.
Nice! Thanks for working on this!
I have a few more comments:
I've address all of review comments. Let me know if there is something else that I should modify or improve. |
@jhpratt It is weird that the changes are so large, but it's almost entirely improvements. There's only one regression, which means it's probably spurious. |
Based on this comment from @m-ou-se:
Shouldn't this PR be marked as |
Beta seems reasonable. Not sure we need a point release for this, though. |
As I was recently told, I'm not sure if even in that case it should be backported, considering this change is a bit more complex than #93394, but it's a discussion that can be had. (But we're getting close to the next release anyway, so a point release seems unlikely at this point.) |
Marking as perf-regression-triaged -- only regression appears to be due to codegen unit reshuffling, not directly related to this PR. |
This broke |
@alice-i-cecile This is expected, see #92137 (comment) for more context about this change and why the breaking change is considered acceptable. Also note that this change will probably be at least back-ported to beta. |
I think I've said this before, but a crater run would be nice to have here. Limited to 2021 edition if it's possible (I don't think it is). |
It will be done as part of the crater run done for every new stable (it's actually done with beta but you see the point). |
Yeah, I just meant to do it before so we don't have to rush a last-minute revert if it breaks too much. |
Beta backport accepted as per compiler team on Zulip Stable backport declined (zulip discussion) @rustbot label +beta-accepted -stable-nominated |
…ulacrum [beta] backports This backports: * Complete removal of #[main] attribute from compiler rust-lang#93753 * Resolve lifetimes for const generic defaults rust-lang#93669 * backport llvm fix for issue 91671. rust-lang#93426 * Fix invalid special casing of the unreachable! macro rust-lang#93179 * Fix hashing for windows paths containing a CurDir component rust-lang#93697 r? `@Mark-Simulacrum`
…imulacrum [stable] 1.59.0 artifacts (second round) This backports (from 1.60, landed in rust-lang#93001): * Move return_self_not_must_use to pedantic rust-lang/rust-clippy#8302 Per a user report on the internals feedback thread, this lint is not behaving well in 1.59. cc `@rust-lang/clippy` -- this is a stable backport of a patch, which we'll likely want to land in fairly short order to be in time for the release Thursday. This PR also includes an adjustment to the release notes to reflect "Fix invalid special casing of the unreachable! macro rust-lang#93179". r? `@Mark-Simulacrum`
This pull-request fix an invalid special casing of the
unreachable!
macro in the same way thepanic!
macro was solved, by adding two new internal only macrosunreachable_2015
andunreachable_2021
edition dependent and turnunreachable!
into a built-in macro that do dispatching. This logic is stolen from thepanic!
macro.This pull-request also adds an internal featureformat_args_capture_non_literal
that allows capturing arguments from formatted string that expanded from macros. The original RFC #2795 mentioned this as a future possibility. This feature is required because of concatenation that needs to be done inside the macro:In summary the new behavior for the
unreachable!
macro with this pr is:Edition 2021:
Edition <= 2018:
Also note that the change in this PR are insta-stable and breaking changes but this a considered as being a bug.
If someone could start a perf run and then a crater run this would be appreciated.
Fixes #92137