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.
This commit is contained in:
Dylan DPC 2022-08-11 22:46:57 +05:30 committed by GitHub
commit 561ea0a746
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<_>>();