about summary refs log tree commit diff
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2024-07-18 22:51:17 +1000
committerZalathar <Zalathar@users.noreply.github.com>2024-07-20 13:29:03 +1000
commit239037ecde3d884ad09bfb95c950021f3bc78da1 (patch)
tree877b3157e07dd7dc556796d29973266c0b1348ba
parent886668cc2ea22a3d52f775961bac06d9499d9e26 (diff)
downloadrust-239037ecde3d884ad09bfb95c950021f3bc78da1.tar.gz
rust-239037ecde3d884ad09bfb95c950021f3bc78da1.zip
Inline `finalize_or_candidate`
-rw-r--r--compiler/rustc_mir_build/src/build/matches/mod.rs24
1 files changed, 7 insertions, 17 deletions
diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs
index d8db08bfb8a..db7aed4306b 100644
--- a/compiler/rustc_mir_build/src/build/matches/mod.rs
+++ b/compiler/rustc_mir_build/src/build/matches/mod.rs
@@ -1624,7 +1624,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
         });
         for candidate in candidates_to_expand.iter_mut() {
             if !candidate.subcandidates.is_empty() {
-                self.finalize_or_candidate(candidate);
+                self.merge_trivial_subcandidates(candidate);
+                self.remove_never_subcandidates(candidate);
             }
         }
         if let Some(last_candidate) = candidates_to_expand.last_mut() {
@@ -1635,8 +1636,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
     }
 
     /// Given a match-pair that corresponds to an or-pattern, expand each subpattern into a new
-    /// subcandidate. Any candidate that has been expanded that way should be passed to
-    /// `finalize_or_candidate` after its subcandidates have been processed.
+    /// subcandidate. Any candidate that has been expanded this way should also be postprocessed
+    /// at the end of [`Self::expand_and_match_or_candidates`].
     fn create_or_subcandidates<'pat>(
         &mut self,
         candidate: &mut Candidate<'pat, 'tcx>,
@@ -1653,8 +1654,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
         candidate.subcandidates[0].false_edge_start_block = candidate.false_edge_start_block;
     }
 
-    /// Simplify subcandidates and remove `is_never` subcandidates.
-    /// The candidate should have been expanded with `create_or_subcandidates`.
+    /// Try to merge all of the subcandidates of the given candidate into one. This avoids
+    /// exponentially large CFGs in cases like `(1 | 2, 3 | 4, ...)`. The candidate should have been
+    /// expanded with `create_or_subcandidates`.
     ///
     /// Given a pattern `(P | Q, R | S)` we (in principle) generate a CFG like
     /// so:
@@ -1706,18 +1708,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
     ///      |
     ///     ...
     /// ```
-    fn finalize_or_candidate(&mut self, candidate: &mut Candidate<'_, 'tcx>) {
-        if candidate.subcandidates.is_empty() {
-            return;
-        }
-
-        self.merge_trivial_subcandidates(candidate);
-        self.remove_never_subcandidates(candidate);
-    }
-
-    /// Try to merge all of the subcandidates of the given candidate into one. This avoids
-    /// exponentially large CFGs in cases like `(1 | 2, 3 | 4, ...)`. The candidate should have been
-    /// expanded with `create_or_subcandidates`.
     ///
     /// Note that this takes place _after_ the subcandidates have participated
     /// in match tree lowering.