Skip to content

Commit

Permalink
Rollup merge of #99110 - audunhalland:match_has_guard_from_candidate,…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
Dylan-DPC committed Aug 11, 2022
2 parents dfddc2f + 2036aea commit 561ea0a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<_>>();

Expand Down

0 comments on commit 561ea0a

Please sign in to comment.