Skip to content

Commit

Permalink
Auto merge of rust-lang#80242 - Nadrieril:explain-and-factor-splittin…
Browse files Browse the repository at this point in the history
…g, r=varkor

Clarify constructor splitting in exhaustiveness checking

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 rust-lang#79284.

r? `@varkor`
`@rustbot` modify labels: +A-exhaustiveness-checking
  • Loading branch information
bors committed Dec 22, 2020
2 parents bb1fbbf + be23694 commit 969b42d
Show file tree
Hide file tree
Showing 4 changed files with 895 additions and 787 deletions.
Loading

0 comments on commit 969b42d

Please sign in to comment.