about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-11-11 18:26:49 +0000
committerbors <bors@rust-lang.org>2021-11-11 18:26:49 +0000
commit936238a92b2f9d6e7afe7dda69b4afd903f96399 (patch)
tree29df31c1ec7b72ac84a9e53ec3775e627f969cb9
parent3d29b6807740db74aeb9c2f626115e519dee4a62 (diff)
parent580d357b5adef605fc731d295ca53ab8532e26fb (diff)
downloadrust-936238a92b2f9d6e7afe7dda69b4afd903f96399.tar.gz
rust-936238a92b2f9d6e7afe7dda69b4afd903f96399.zip
Auto merge of #90746 - nnethercote:opt-pattern-matching, r=Nadrieril
Optimize pattern matching

These commits speed up the `match-stress-enum` benchmark, which is very artificial, but the changes are simple enough that it's probably worth doing.

r? `@Nadrieril`
-rw-r--r--compiler/rustc_mir_build/src/thir/pattern/usefulness.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs
index d959d2f7f6f..067b0506e30 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs
@@ -797,7 +797,7 @@ fn is_useful<'p, 'tcx>(
         return ret;
     }
 
-    assert!(rows.iter().all(|r| r.len() == v.len()));
+    debug_assert!(rows.iter().all(|r| r.len() == v.len()));
 
     let ty = v.head().ty();
     let is_non_exhaustive = cx.is_foreign_non_exhaustive_enum(ty);