summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_mir_build/src/build/matches/simplify.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_mir_build/src/build/matches/simplify.rs')
-rw-r--r--compiler/rustc_mir_build/src/build/matches/simplify.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/compiler/rustc_mir_build/src/build/matches/simplify.rs b/compiler/rustc_mir_build/src/build/matches/simplify.rs
index 924d2f555..f6b1955fd 100644
--- a/compiler/rustc_mir_build/src/build/matches/simplify.rs
+++ b/compiler/rustc_mir_build/src/build/matches/simplify.rs
@@ -73,8 +73,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
{
existing_bindings.extend_from_slice(&new_bindings);
mem::swap(&mut candidate.bindings, &mut existing_bindings);
- candidate.subcandidates =
- self.create_or_subcandidates(candidate, place.clone(), pats);
+ candidate.subcandidates = self.create_or_subcandidates(candidate, &place, pats);
return true;
}
@@ -127,7 +126,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
fn create_or_subcandidates<'pat>(
&mut self,
candidate: &Candidate<'pat, 'tcx>,
- place: PlaceBuilder<'tcx>,
+ place: &PlaceBuilder<'tcx>,
pats: &'pat [Box<Pat<'tcx>>],
) -> Vec<Candidate<'pat, 'tcx>> {
pats.iter()
@@ -156,10 +155,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
ascription: thir::Ascription { ref annotation, variance },
} => {
// Apply the type ascription to the value at `match_pair.place`, which is the
- if let Ok(place_resolved) = match_pair.place.clone().try_upvars_resolved(self) {
+ if let Some(source) = match_pair.place.try_to_place(self) {
candidate.ascriptions.push(Ascription {
annotation: annotation.clone(),
- source: place_resolved.into_place(self),
+ source,
variance,
});
}
@@ -183,10 +182,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
ref subpattern,
is_primary: _,
} => {
- if let Ok(place_resolved) = match_pair.place.clone().try_upvars_resolved(self) {
+ if let Some(source) = match_pair.place.try_to_place(self) {
candidate.bindings.push(Binding {
span: match_pair.pattern.span,
- source: place_resolved.into_place(self),
+ source,
var_id: var,
binding_mode: mode,
});
@@ -264,10 +263,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let irrefutable = adt_def.variants().iter_enumerated().all(|(i, v)| {
i == variant_index || {
self.tcx.features().exhaustive_patterns
- && v.inhabited_predicate(self.tcx, adt_def)
+ && !v
+ .inhabited_predicate(self.tcx, adt_def)
.subst(self.tcx, substs)
- .apply_any_module(self.tcx, self.param_env)
- != Some(true)
+ .apply_ignore_module(self.tcx, self.param_env)
}
}) && (adt_def.did().is_local()
|| !adt_def.is_variant_list_non_exhaustive());