-
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
De-abuse TyKind::Error in exhaustiveness checking #71930
De-abuse TyKind::Error in exhaustiveness checking #71930
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
May I request a perf run on this? I'm not confident I managed to preserve performance |
@bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit e5667234a7fe2ca921766a197933229586749832 with merge 10bf6df2a72191317fadc1859f3d849707705018... |
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 |
☀️ Try build successful - checks-actions, checks-azure |
Queued 10bf6df2a72191317fadc1859f3d849707705018 with parent f8d394e, future comparison URL. |
cc @eddyb (who I was working with on the tykind::error effort) |
It looks like the CI failure is a bug:
|
Finished benchmarking try commit 10bf6df2a72191317fadc1859f3d849707705018, comparison URL. |
Perf looks neutral |
The regression was caused by 624ff54 . The regressed test is as follows: fn f() -> ! {
panic!("quux")
}
fn g() -> isize {
match f() {
true => 1,
false => 0,
}
} The reason it now fails is because instead of using the type of the first pattern to do our computations, we now use the type of the scrutinee. But that shouldn't make a difference, should it? Somehow here the scrutinee is given the type fn g() -> isize {
let x = f();
match x {
true => 1,
false => 0,
}
} So I don't think it's my fault; that looks like a type inference issue to me. For context, the type of the scrutinee is retrieved here
|
|
e566723
to
a546f29
Compare
@matthewjasper Thanks, that was indeed the issue! |
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 |
@matthewjasper Actually, your suggestion regressed this: fn from(never: !) -> TryFromIntError {
match never {}
} Apparently |
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 |
|
Yeah I didn't mean to push that yet, I'm still hoping that @matthewjasper might pop in and figure out the arcane invocation needed to get the correct type x) |
19bfef8
to
c6f0947
Compare
@varkor I couldn't reproduce the perf impact locally, so I rebased on current master, but I still don't see it. On my machine I see a consistent ~1% improvement on the unicode_normalization 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.
Thanks @Nadrieril, these comments are great :) I spotted one typo, but apart from that, I think this is ready to go.
I'm inclined to treat the perf results as negligible, especially if you see an improvement lately, but we'll make sure the PR isn't rolled up, so if it does have an effect, it'll be easier to track down. @bors rollup=never |
Co-authored-by: varkor <[email protected]>
Thanks! @bors r+ |
📌 Commit 4c6510b has been approved by |
@bors r=varkor |
📌 Commit d7e1d5f has been approved by |
🌲 The tree is currently closed for pull requests below priority 9000, this pull request will be tested once the tree is reopened |
☀️ Test successful - checks-azure |
Exhaustiveness checking: work around type normalization issues This should resolve rust-lang#72476 and probably rust-lang#72467. This is a bit hacky but that's actually what the code was doing before rust-lang#71930. I'm essentially reverting rust-lang@e5a2cd5. So despite being hacky, it's been tried and tested (so much so that code relies on it now x)). Only the third commit does anything interesting.
Replaces #71074. Context: #70866.
In order to remove the use of
TyKind::Error
, I had to make sure we skip over those fields whose inhabitedness should not be observed. This is potentially error-prone however, since we must be careful not to mix filtered and unfiltered lists of patterns. I managed to hide away most of the filtering behind a newFields
struct, that I used everywhere relevant. I quite like the result; I think the twin concepts ofConstructor
andFields
make a good mental model.As usual, I tried to separate commits that shuffle code around from commits that require more thought to review.
cc @varkor @Centril