-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Associated-const ranges in patterns are miscompiled in beta #57960
Comments
triage: P-high, A-NLL, NLL-complete, assigning to self. |
cc @davidtwco |
I have confirmed that the bug appears to be specifically injected by commit 4be7214 (I've skimmed over that commit several times and still can't see the problem, but I'm going to try again now. Maybe the actual issue is that we are miscompiling |
Well this is making my spidey-sense tingle:
rust/src/librustc_mir/build/matches/test.rs Lines 134 to 139 in 1aa2506
but even when that returns false, it seems like that would only imply that we fall through to presumably more general purpose code here: rust/src/librustc_mir/build/matches/mod.rs Line 1041 in 1aa2506
(still looking. Going to add a bit of instrumentation to these parts of the compiler.) |
Lower constant patterns with ascribed types. Fixes #57960. This PR fixes a bug introduced by #55937 which started checking user type annotations for associated type patterns. Where lowering a associated constant expression would previously return a `PatternKind::Constant`, it now returns a `PatternKind::AscribeUserType` with a `PatternKind::Constant` inside, this PR unwraps that to access the constant pattern inside and behaves as before. r? @pnkfelix
This code demonstrates the problem (playpen):
With stable-1.32.0 it prints
3
. With beta-1.33.0 it wrongly prints1
.Beta also produces these wrong warnings:
It seems that Rustc decides, that the first arm covers the whole range of a
u8
and optimizes out the other arms before they even reach MIR.The code is very similar to this testcase.
But the testcase does not test that the other arms can be reached.
I was able to bisect the regression to #55937.
(This issue seems similar to #57894, but the reduced testcase there does not
use any associated consts)
The text was updated successfully, but these errors were encountered: