Skip to content

Commit 7b69082

Browse files
committed
let_chains: fix ICE in generator_interior
1 parent 5cf33a6 commit 7b69082

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/librustc_typeck/check/generator_interior.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,25 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
247247
}
248248
_ => intravisit::walk_expr(self, expr),
249249
},
250+
ExprKind::Match(
251+
Expr { kind: ExprKind::Let(pat, scrutinee), .. },
252+
[then_arm, else_arm],
253+
hir::MatchSource::IfLetDesugar { .. },
254+
) => {
255+
// HACK(let_chains, Centril): In HAIR lowering we currently adjust this
256+
// to `match scrutinee { pat => then_arm.body, _ => else_arm.body }`.
257+
// For consistency, we need to replicate the visiting order in
258+
// `intravisit::walk_expr` with respect to `ExprKind::Match`.
259+
self.visit_expr(scrutinee);
260+
// This is for the `then_arm`. NOTE(Centril): Preserve the order in `intravisit`!
261+
self.visit_id(then_arm.hir_id);
262+
// NOTE(Centril): We are using `pat` here as opposed to `then_arm.pat`!
263+
self.visit_pat(pat);
264+
assert!(then_arm.guard.is_none());
265+
self.visit_expr(&then_arm.body);
266+
syntax::walk_list!(self, visit_attribute, then_arm.attrs);
267+
self.visit_arm(else_arm);
268+
}
250269
_ => intravisit::walk_expr(self, expr),
251270
}
252271

0 commit comments

Comments
 (0)