Fix handling of empty types in patterns. - #38069
Conversation
|
(rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Style: usually else is on the same line as the closing bracket.
There was a problem hiding this comment.
Why is it necessary to change this example?
There was a problem hiding this comment.
ah nevermind, because this triggers for E0001 and not for unreachable_patterns
|
cc @brson because this would be a new (insta-stable?) feature |
There was a problem hiding this comment.
Why do we keep this as an error even if there is an _ pattern? Is there a strong reason?
There was a problem hiding this comment.
Not sure, it was @eddyb's suggestion. If that becomes a lint then we don't get to use E0001 at all though.
There was a problem hiding this comment.
The annoying thing is that a lint loses the help message, but if everyone else is fine with it, then sure, you can remove this special case.
|
Seems like we need some more test -- for example, I don't see any tests covering the private field cases, nor the "don't need to match variants" code, right? (is that because this is a WIP?) |
603dff6 to
e885c88
Compare
Yep, it should all be there now though. |
|
It might be worth @arielb1 having a look at this too, seeing as they wrote the match checking code that I've fiddled with. |
|
So a quick summary of these changes: (Most) unreachable patterns now generate warnings instead of errors. I've added a new Unreachable patterns that used to sneak past the pattern-match checks no longer produce an I've fixed
Removed the special-casing that made Correct type information is carried on dummy wildcard patterns. This was necessary to make the above change but I suspect it's also a more general bugfix. It used to be possible for the pattern-match algs to be handling a dummy
|
|
☔ The latest upstream changes (presumably #38053) made this pull request unmergeable. Please resolve the merge conflicts. |
8a09338 to
b9e51f9
Compare
|
@nikomatsakis this is ready now btw. @brson any chance I could get a crater run on this? |
|
@canndrew sorry for delay. Mozilla all hands didn't leave much time for reviewing. I'm going to be on vacation next week but will try to find time, else perhaps someone else can/should review. |
|
@nikomatsakis That's alright. I was just a bit angsty that this would get ignored for a month or so and eventually bit-rot like the last PR for this did. I understand you guys have a very full plate though. Probably @arielb1 would be the best person to review this? |
There was a problem hiding this comment.
This should be #[deny(unreachable_patterns)]
There was a problem hiding this comment.
I'm worried that the recursion here might cause things to be slow. Could you try adding a cache somewhere?
|
I've refactored Then |
|
Anyone know what happened to travis there? |
|
@canndrew I think Travis has been busted for almost a week now. |
|
Is there anything more I can do to help get this reviewed? |
|
@canndrew back now, sorry about that. |
|
Will review. |
|
Sorry for delay. I am doing a bit of reading up on the general algorithm since I'm feeling ill-equipped to judge this patch. =) |
|
That's cool.
Algorithm-wise these should be the only relevant changes and should be enough to make it correctly handle empty types. |
|
@bors r=nikomatsakis force |
|
@bors retry |
|
@bors r=nikomatsakis |
|
📌 Commit 275c19d has been approved by |
|
☀️ Test successful - status-appveyor, status-travis |
|
I suggest a |
|
Done. |
Fix for #12609.