-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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 matches
by None in is_none
method on Option
#110456
Conversation
r? @m-ou-se (rustbot has picked a reviewer for you, use r? to override) |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit f8e6844 with merge bd51390ff492a775ea7ad9d80516043a5a7627a6... |
Can we actually solve this on the compiler/llvm side instead? This looks like a bug in the compiler — we forget somewhere that define noundef i32 @_ZN7example1f17h05bced40beed593aE(i32 noundef %0, i32 returned %1) unnamed_addr #0 !dbg !6 {
start:
%2 = icmp ne i32 %0, 1, !dbg !11
tail call void @llvm.assume(i1 %2), !dbg !23
%switch = icmp eq i32 %0, 0, !dbg !24
br i1 %switch, label %bb4, label %bb6, !dbg !24
bb4: ; preds = %start
tail call void @_ZN4core9panicking5panic17h9caa3ddd0cccb1d2E(ptr noalias noundef nonnull readonly align 1 @alloc_5f55955de67e57c79064b537689facea, i64 noundef 43, ptr noalias noundef nonnull readonly align 8 dereferenceable(24) @alloc_b5761c36d4207a96188a90095c0f36d6) #3, !dbg !27
unreachable, !dbg !27
bb6: ; preds = %start
ret i32 %1, !dbg !28
} Note: we assume Adding a I'm not sure how easy it is to fix this (cc @rust-lang/wg-mir-opt?), but IMO we should really try to fix this in the compiler, as it should have an effect on more code. |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
@WaffleLapkin. I like it more when the method explicitly says what it does without delegate to other code. I also wanted to offer a patch for Result, but the problem was not reproduced there, so I left it only for Option. I would like to add this patch too if there is no fundamental reason not to add it. |
@heckad I think there is nothing particularly wrong with this change, I just want to make sure we don't forget to fix the compiler :) btw you can write |
Finished benchmarking commit (bd51390ff492a775ea7ad9d80516043a5a7627a6): comparison URL. Overall result: ❌ regressions - 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 is a highly reliable metric that was used to determine the overall result at the top of this comment.
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.
CyclesResultsThis 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.
|
The problem seems to be a regression. While assume doesn't work on stable, here's a comparison with unreachable_unchecked: https://godbolt.org/z/K9x8eY6o8 1.68 gives just about what you'd expect, while nightly (and beta, too, if you can coerce it to not die) doesn't. |
I've opened an issue to track the regression: #110551 |
Now it's just a stylistic change. If you don't need it, you can close it. |
assume
don't understand inversion. Code likecompiles into
but
compiles into
This patch solves that problem.