Skip to content

Commit daf93df

Browse files
restore control flow on error in EUV
1 parent b7bc90f commit daf93df

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

compiler/rustc_hir_typeck/src/expr_use_visitor.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,11 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
252252

253253
hir::ExprKind::Match(ref discr, arms, _) => {
254254
let discr_place = return_if_err!(self.mc.cat_expr(discr));
255-
self.maybe_read_scrutinee(
255+
return_if_err!(self.maybe_read_scrutinee(
256256
discr,
257257
discr_place.clone(),
258258
arms.iter().map(|arm| arm.pat),
259-
);
259+
));
260260

261261
// treatment of the discriminant is handled while walking the arms.
262262
for arm in arms {
@@ -390,15 +390,15 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
390390
discr: &Expr<'_>,
391391
discr_place: PlaceWithHirId<'tcx>,
392392
pats: impl Iterator<Item = &'t hir::Pat<'t>>,
393-
) {
393+
) -> Result<(), ()> {
394394
// Matching should not always be considered a use of the place, hence
395395
// discr does not necessarily need to be borrowed.
396396
// We only want to borrow discr if the pattern contain something other
397397
// than wildcards.
398398
let ExprUseVisitor { ref mc, body_owner: _, delegate: _ } = *self;
399399
let mut needs_to_be_read = false;
400400
for pat in pats {
401-
return_if_err!(mc.cat_pattern(discr_place.clone(), pat, |place, pat| {
401+
mc.cat_pattern(discr_place.clone(), pat, |place, pat| {
402402
match &pat.kind {
403403
PatKind::Binding(.., opt_sub_pat) => {
404404
// If the opt_sub_pat is None, than the binding does not count as
@@ -453,7 +453,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
453453
// examined
454454
}
455455
}
456-
}));
456+
})?
457457
}
458458

459459
if needs_to_be_read {
@@ -474,6 +474,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
474474
// that the discriminant has been initialized.
475475
self.walk_expr(discr);
476476
}
477+
Ok(())
477478
}
478479

479480
fn walk_local<F>(
@@ -490,7 +491,11 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
490491
f(self);
491492
if let Some(els) = els {
492493
// borrowing because we need to test the discriminant
493-
self.maybe_read_scrutinee(expr, expr_place.clone(), from_ref(pat).iter());
494+
return_if_err!(self.maybe_read_scrutinee(
495+
expr,
496+
expr_place.clone(),
497+
from_ref(pat).iter()
498+
));
494499
self.walk_block(els)
495500
}
496501
self.walk_irrefutable_pat(&expr_place, &pat);

compiler/rustc_hir_typeck/src/upvar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2184,7 +2184,7 @@ fn determine_place_ancestry_relation<'tcx>(
21842184
place_a: &Place<'tcx>,
21852185
place_b: &Place<'tcx>,
21862186
) -> PlaceAncestryRelation {
2187-
// If Place A and Place B, don't start off from the same root variable, they are divergent.
2187+
// If Place A and Place B don't start off from the same root variable, they are divergent.
21882188
if place_a.base != place_b.base {
21892189
return PlaceAncestryRelation::Divergent;
21902190
}

0 commit comments

Comments
 (0)