-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
Refactor pattern-matching usefulness algorithm #65160
Commits on Oct 18, 2019
-
Configuration menu - View commit details
-
Copy full SHA for c9b33ee - Browse repository at this point
Copy the full SHA c9b33eeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3ea9c9c - Browse repository at this point
Copy the full SHA 3ea9c9cView commit details -
Clarify and fix the explanation of the algorithm
There was a bit of confusion between individual patterns and lists of patterns, and index mismatches linked to that. This introduces a vocabulary of "pattern-stacks" to provide a clearer mental model of what is happening. This also adds examples.
Configuration menu - View commit details
-
Copy full SHA for f983460 - Browse repository at this point
Copy the full SHA f983460View commit details -
Configuration menu - View commit details
-
Copy full SHA for 77e3a95 - Browse repository at this point
Copy the full SHA 77e3a95View commit details -
Configuration menu - View commit details
-
Copy full SHA for e1b7627 - Browse repository at this point
Copy the full SHA e1b7627View commit details -
Remove duplicate logic in compute_missing_constructors
This is equivalent to the previous code in terms of performance. The expensive path is clearly identical. The fast path is also the same, because in both cases we loop until we get a non-empty `refined_ctors`, and then stop there. So the new code doesn't compute anything more than the previous did.
Configuration menu - View commit details
-
Copy full SHA for a075db8 - Browse repository at this point
Copy the full SHA a075db8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7ee9cb7 - Browse repository at this point
Copy the full SHA 7ee9cb7View commit details -
Configuration menu - View commit details
-
Copy full SHA for a150d97 - Browse repository at this point
Copy the full SHA a150d97View commit details -
Configuration menu - View commit details
-
Copy full SHA for f0e8c78 - Browse repository at this point
Copy the full SHA f0e8c78View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8a2274b - Browse repository at this point
Copy the full SHA 8a2274bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0f5e02e - Browse repository at this point
Copy the full SHA 0f5e02eView commit details -
Configuration menu - View commit details
-
Copy full SHA for c95b7ae - Browse repository at this point
Copy the full SHA c95b7aeView commit details -
Configuration menu - View commit details
-
Copy full SHA for ea3fe4e - Browse repository at this point
Copy the full SHA ea3fe4eView commit details -
Configuration menu - View commit details
-
Copy full SHA for d4cc125 - Browse repository at this point
Copy the full SHA d4cc125View commit details -
Configuration menu - View commit details
-
Copy full SHA for 501cf3a - Browse repository at this point
Copy the full SHA 501cf3aView commit details -
Configuration menu - View commit details
-
Copy full SHA for b2ae93c - Browse repository at this point
Copy the full SHA b2ae93cView commit details -
Rework the exhaustiveness algorithm to better integrate meta-construc…
…tors This is strictly a refactoring: the new algorithm does exactly the same work as the previous one. However, it replaces the ad-hoc handling of ranges and slice patterns with a unified approach, using meta-constructors. This should improve both code legibility and future extensibility.
Configuration menu - View commit details
-
Copy full SHA for 89df721 - Browse repository at this point
Copy the full SHA 89df721View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1bd18d2 - Browse repository at this point
Copy the full SHA 1bd18d2View commit details -
Configuration menu - View commit details
-
Copy full SHA for ad28919 - Browse repository at this point
Copy the full SHA ad28919View commit details -
Configuration menu - View commit details
-
Copy full SHA for ec57a89 - Browse repository at this point
Copy the full SHA ec57a89View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6d9a35d - Browse repository at this point
Copy the full SHA 6d9a35dView commit details -
Match constructor first instead of type first in various functions
Needed since there may now be meta-constructors for the given type. Also implement the trivial MissingConstructors cases for some of those functions.
Configuration menu - View commit details
-
Copy full SHA for 6e392f0 - Browse repository at this point
Copy the full SHA 6e392f0View commit details -
Configuration menu - View commit details
-
Copy full SHA for d9871b8 - Browse repository at this point
Copy the full SHA d9871b8View commit details -
Configuration menu - View commit details
-
Copy full SHA for cf90304 - Browse repository at this point
Copy the full SHA cf90304View commit details -
Configuration menu - View commit details
-
Copy full SHA for 931d7a9 - Browse repository at this point
Copy the full SHA 931d7a9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 142df8b - Browse repository at this point
Copy the full SHA 142df8bView commit details -
Configuration menu - View commit details
-
Copy full SHA for cb4715d - Browse repository at this point
Copy the full SHA cb4715dView commit details -
Configuration menu - View commit details
-
Copy full SHA for a1b3800 - Browse repository at this point
Copy the full SHA a1b3800View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6337864 - Browse repository at this point
Copy the full SHA 6337864View commit details -
Configuration menu - View commit details
-
Copy full SHA for c0359ce - Browse repository at this point
Copy the full SHA c0359ceView commit details -
Configuration menu - View commit details
-
Copy full SHA for 33273f2 - Browse repository at this point
Copy the full SHA 33273f2View commit details -
Configuration menu - View commit details
-
Copy full SHA for cb3452c - Browse repository at this point
Copy the full SHA cb3452cView commit details -
Gather together usefulness tests
I took most tests that were testing only for match exhaustiveness, pattern refutability or match arm reachability, and put them in the same test folder.
Configuration menu - View commit details
-
Copy full SHA for ad78eff - Browse repository at this point
Copy the full SHA ad78effView commit details -
Configuration menu - View commit details
-
Copy full SHA for a91cdd4 - Browse repository at this point
Copy the full SHA a91cdd4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8e89f3c - Browse repository at this point
Copy the full SHA 8e89f3cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9ae4c52 - Browse repository at this point
Copy the full SHA 9ae4c52View commit details -
Use Wildcard instead of MissingConstructors when relevant
This both simplifies the missing constructors codepath and exactly matches what we want for witness construction. So this behaviour of witness construction isn't an ad-hoc tweak anymore, it also makes semantic sense.
Configuration menu - View commit details
-
Copy full SHA for b3de6fd - Browse repository at this point
Copy the full SHA b3de6fdView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4be3802 - Browse repository at this point
Copy the full SHA 4be3802View commit details -
Configuration menu - View commit details
-
Copy full SHA for d12b172 - Browse repository at this point
Copy the full SHA d12b172View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2687140 - Browse repository at this point
Copy the full SHA 2687140View commit details -
Extract constructor_intersects_pattern function
This reverses changes from rust-lang#65089, but I need this temporarily for rebase to be tractable.
Configuration menu - View commit details
-
Copy full SHA for 1f8d93c - Browse repository at this point
Copy the full SHA 1f8d93cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1b65bec - Browse repository at this point
Copy the full SHA 1b65becView commit details -
Configuration menu - View commit details
-
Copy full SHA for 12bb3b7 - Browse repository at this point
Copy the full SHA 12bb3b7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 022c620 - Browse repository at this point
Copy the full SHA 022c620View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0ab764b - Browse repository at this point
Copy the full SHA 0ab764bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 956838d - Browse repository at this point
Copy the full SHA 956838dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1793ad5 - Browse repository at this point
Copy the full SHA 1793ad5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 527fe65 - Browse repository at this point
Copy the full SHA 527fe65View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0d58ead - Browse repository at this point
Copy the full SHA 0d58eadView commit details -
Make exhaustiveness error message more consistent for slice patterns
Now it doesn't depend on the rather arbitrary (from the user's point of view) max_slice_length limit. When slice_patterns is not enabled, and the missing pattern is e.g. `[_, _, ..]`, the message will report that `[_, _]` is missing. Previously, it would sometimes report a few more missing patterns but of course never all of them. When the feature is enabled, the message correctly reports that `[_, _, ..]` is missing.
Configuration menu - View commit details
-
Copy full SHA for 0b353b3 - Browse repository at this point
Copy the full SHA 0b353b3View commit details -
Configuration menu - View commit details
-
Copy full SHA for cf4dc88 - Browse repository at this point
Copy the full SHA cf4dc88View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1e43487 - Browse repository at this point
Copy the full SHA 1e43487View commit details -
Configuration menu - View commit details
-
Copy full SHA for c8ac41e - Browse repository at this point
Copy the full SHA c8ac41eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 244ac8d - Browse repository at this point
Copy the full SHA 244ac8dView commit details -
Configuration menu - View commit details
-
Copy full SHA for ad09cc5 - Browse repository at this point
Copy the full SHA ad09cc5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 47ee628 - Browse repository at this point
Copy the full SHA 47ee628View commit details -
Note that where we previously ran `max_slice_len` with input having not only matrix_head_ctors but also all of v_constructors. Now we run it on matrix_head_ctors and one constructor of v_constructors at a time. In the presence of or-patterns, those two things might differ. However the new behaviour is still valid with regards to the specified semantics of split_meta_constructor.
Configuration menu - View commit details
-
Copy full SHA for c6d1cad - Browse repository at this point
Copy the full SHA c6d1cadView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0c0fe9f - Browse repository at this point
Copy the full SHA 0c0fe9fView commit details -
Splitting variable-length slices now respects the required invariant
The previous behaviour did not respect the invariant specified in the description of the algorithm. As a nice side-effect, exhaustiveness errors have improved when slice_patterns is enabled; they now capture all missing lengths instead of the shortest. Note: this changes diagnostics, but only when slice_patterns is enabled.
Configuration menu - View commit details
-
Copy full SHA for 6b4426a - Browse repository at this point
Copy the full SHA 6b4426aView commit details -
It was introduced to carry max_slice_length so we don't need it anymore.
Configuration menu - View commit details
-
Copy full SHA for 72c3a68 - Browse repository at this point
Copy the full SHA 72c3a68View commit details -
Several comments were leftover from before the rework of the algorithm and didn't make sens anymore.
Configuration menu - View commit details
-
Copy full SHA for f5d833f - Browse repository at this point
Copy the full SHA f5d833fView commit details -
This makes the conversions from/to Const better localized. In particular, eval_bits only happens in IntRange::from_ctor.
Configuration menu - View commit details
-
Copy full SHA for 94227f5 - Browse repository at this point
Copy the full SHA 94227f5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 60021ce - Browse repository at this point
Copy the full SHA 60021ceView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3d0945d - Browse repository at this point
Copy the full SHA 3d0945dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5badbb7 - Browse repository at this point
Copy the full SHA 5badbb7View commit details -
Configuration menu - View commit details
-
Copy full SHA for defc66d - Browse repository at this point
Copy the full SHA defc66dView commit details -
Configuration menu - View commit details
-
Copy full SHA for d8b71d4 - Browse repository at this point
Copy the full SHA d8b71d4View commit details -
Move range exhaustiveness check to IntRange::intersection
Only IntRange needs to worry about range exhaustiveness really.
Configuration menu - View commit details
-
Copy full SHA for 66dac52 - Browse repository at this point
Copy the full SHA 66dac52View commit details -
Configuration menu - View commit details
-
Copy full SHA for b85e4be - Browse repository at this point
Copy the full SHA b85e4beView commit details -
Configuration menu - View commit details
-
Copy full SHA for eea0b79 - Browse repository at this point
Copy the full SHA eea0b79View commit details -
Configuration menu - View commit details
-
Copy full SHA for 34b0774 - Browse repository at this point
Copy the full SHA 34b0774View commit details -
Configuration menu - View commit details
-
Copy full SHA for 087adfe - Browse repository at this point
Copy the full SHA 087adfeView commit details -
Configuration menu - View commit details
-
Copy full SHA for a66dcd5 - Browse repository at this point
Copy the full SHA a66dcd5View commit details -
Configuration menu - View commit details
-
Copy full SHA for a2624f2 - Browse repository at this point
Copy the full SHA a2624f2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 79efdb4 - Browse repository at this point
Copy the full SHA 79efdb4View commit details -
Clarify why the naive algorithm may not terminate
As suggested by arielb1 rust-lang#65160 (review)
Configuration menu - View commit details
-
Copy full SHA for 1f6a5a5 - Browse repository at this point
Copy the full SHA 1f6a5a5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 455095a - Browse repository at this point
Copy the full SHA 455095aView commit details -
Configuration menu - View commit details
-
Copy full SHA for d379a43 - Browse repository at this point
Copy the full SHA d379a43View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1de1683 - Browse repository at this point
Copy the full SHA 1de1683View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3aa5fb3 - Browse repository at this point
Copy the full SHA 3aa5fb3View commit details -
Configuration menu - View commit details
-
Copy full SHA for c956c65 - Browse repository at this point
Copy the full SHA c956c65View commit details -
Configuration menu - View commit details
-
Copy full SHA for 368c71b - Browse repository at this point
Copy the full SHA 368c71bView commit details -
Compute constructors on PatStack construction
All the constructed PatStacks end up having `head_ctors` called on them, so this does not unnecessarily precompute anything.
Configuration menu - View commit details
-
Copy full SHA for 6df1815 - Browse repository at this point
Copy the full SHA 6df1815View commit details -
Stop checking that cached constructors are valid. Avoid cloning constructors when not necessary.
Configuration menu - View commit details
-
Copy full SHA for ed3ea67 - Browse repository at this point
Copy the full SHA ed3ea67View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9c3682f - Browse repository at this point
Copy the full SHA 9c3682fView commit details -
Don't use SmallVec when we could use Option
This reverts some of the or-patterns future-proofing, for the sake of performance.
Configuration menu - View commit details
-
Copy full SHA for b052036 - Browse repository at this point
Copy the full SHA b052036View commit details -
Configuration menu - View commit details
-
Copy full SHA for fd3ec66 - Browse repository at this point
Copy the full SHA fd3ec66View commit details