Skip to content

Clarify constructor splitting in exhaustiveness checking#80242

Merged
bors merged 13 commits intorust-lang:masterfrom
Nadrieril:explain-and-factor-splitting
Dec 23, 2020
Merged

Clarify constructor splitting in exhaustiveness checking#80242
bors merged 13 commits intorust-lang:masterfrom
Nadrieril:explain-and-factor-splitting

Conversation

@Nadrieril
Copy link
Copy Markdown
Member

I reworked the explanation of the algorithm completely to make it properly account for the various extensions we've added. This includes constructor splitting, which was previously not clearly included in the algorithm. This makes wildcards less magical; I added some detailed examples; and this distinguishes clearly between constructors that only make sense in patterns (like ranges) and those that make sense for values (like Some). This reformulation had been floating around in my mind for a while, and I'm quite happy with how it turned out. Let me know how you feel about it.
I also factored out all three cases of splitting (wildcards, ranges and slices) into dedicated structs to encapsulate the complicated bits.
I measured no perf impact but I don't trust my local measurements for refactors since #79284.

r? @varkor
@rustbot modify labels: +A-exhaustiveness-checking

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants