about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNadrieril <nadrieril+git@gmail.com>2019-11-03 21:22:14 +0000
committerNadrieril <nadrieril+git@gmail.com>2019-11-05 17:59:01 +0000
commit909ec370286b193f67e738e7b9d6437cf32c014c (patch)
tree630cb47f4cb6138e511007aa990a21725927bbef
parente092a170528c964dddb0ed9764e8593d9ac8b370 (diff)
downloadrust-909ec370286b193f67e738e7b9d6437cf32c014c.tar.gz
rust-909ec370286b193f67e738e7b9d6437cf32c014c.zip
Simpler code path for subtracting from FixedLenSlice
-rw-r--r--src/librustc_mir/hair/pattern/_match.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs
index d0597817d32..31984daa5df 100644
--- a/src/librustc_mir/hair/pattern/_match.rs
+++ b/src/librustc_mir/hair/pattern/_match.rs
@@ -672,7 +672,15 @@ impl<'tcx> Constructor<'tcx> {
                     vec![self.clone()]
                 }
             }
-            FixedLenSlice(_) | VarLenSlice(_) => {
+            FixedLenSlice(self_len) => {
+                let overlaps = |c: &Constructor<'_>| match c {
+                    FixedLenSlice(other_len) => other_len == self_len,
+                    VarLenSlice(other_len) => other_len <= self_len,
+                    _ => false,
+                };
+                if other_ctors.iter().any(overlaps) { vec![] } else { vec![self.clone()] }
+            }
+            VarLenSlice(_) => {
                 let mut remaining_ctors = if let VarLenSlice(len) = self {
                     (*len..pcx.max_slice_length + 1).map(FixedLenSlice).collect()
                 } else {