about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-08-11 22:46:57 +0530
committerGitHub <noreply@github.com>2022-08-11 22:46:57 +0530
commit561ea0a746fae943eb6c895a71fb8cbfce22e03a (patch)
treee0b4f21ae4f501b836da5f35bfd235246bf08460
parentdfddc2f9183b38183791f11887a1d608bb220878 (diff)
parent2036aea18e9a525fa7180240c657944fc6838035 (diff)
downloadrust-561ea0a746fae943eb6c895a71fb8cbfce22e03a.tar.gz
rust-561ea0a746fae943eb6c895a71fb8cbfce22e03a.zip
Rollup merge of #99110 - audunhalland:match_has_guard_from_candidate, r=pnkfelix
Determine match_has_guard from candidates instead of looking up thir table again

Currently looking through mir build of matches because of interest in deref patterns. Finding some micro-optimizable things.
-rw-r--r--compiler/rustc_mir_build/src/build/matches/mod.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs
index cefb5f36b6a..ce38283724d 100644
--- a/compiler/rustc_mir_build/src/build/matches/mod.rs
+++ b/compiler/rustc_mir_build/src/build/matches/mod.rs
@@ -170,7 +170,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
 
         let mut arm_candidates = self.create_match_candidates(scrutinee_place.clone(), &arms);
 
-        let match_has_guard = arms.iter().copied().any(|arm| self.thir[arm].guard.is_some());
+        let match_has_guard = arm_candidates.iter().any(|(_, candidate)| candidate.has_guard);
         let mut candidates =
             arm_candidates.iter_mut().map(|(_, candidate)| candidate).collect::<Vec<_>>();