Skip to content

Commit 928b3da

Browse files
committed
Auto merge of #119349 - zetanumbers:liveness-pass-refactor, r=WaffleLapkin
refactor(liveness): move walk_expr outside of every match branch
2 parents 8e34642 + 4bb7a12 commit 928b3da

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

compiler/rustc_passes/src/liveness.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,6 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
405405
if let Res::Local(_var_hir_id) = path.res {
406406
self.add_live_node_for_node(expr.hir_id, ExprNode(expr.span, expr.hir_id));
407407
}
408-
intravisit::walk_expr(self, expr);
409408
}
410409
hir::ExprKind::Closure(closure) => {
411410
// Interesting control flow (for loops can contain labeled
@@ -425,12 +424,10 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
425424
}));
426425
}
427426
self.set_captures(expr.hir_id, call_caps);
428-
intravisit::walk_expr(self, expr);
429427
}
430428

431429
hir::ExprKind::Let(let_expr) => {
432430
self.add_from_pat(let_expr.pat);
433-
intravisit::walk_expr(self, expr);
434431
}
435432

436433
// live nodes required for interesting control flow:
@@ -439,11 +436,9 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
439436
| hir::ExprKind::Loop(..)
440437
| hir::ExprKind::Yield(..) => {
441438
self.add_live_node_for_node(expr.hir_id, ExprNode(expr.span, expr.hir_id));
442-
intravisit::walk_expr(self, expr);
443439
}
444440
hir::ExprKind::Binary(op, ..) if op.node.is_lazy() => {
445441
self.add_live_node_for_node(expr.hir_id, ExprNode(expr.span, expr.hir_id));
446-
intravisit::walk_expr(self, expr);
447442
}
448443

449444
// otherwise, live nodes are not required:
@@ -474,10 +469,9 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
474469
| hir::ExprKind::Type(..)
475470
| hir::ExprKind::Err(_)
476471
| hir::ExprKind::Path(hir::QPath::TypeRelative(..))
477-
| hir::ExprKind::Path(hir::QPath::LangItem(..)) => {
478-
intravisit::walk_expr(self, expr);
479-
}
472+
| hir::ExprKind::Path(hir::QPath::LangItem(..)) => {}
480473
}
474+
intravisit::walk_expr(self, expr);
481475
}
482476
}
483477

0 commit comments

Comments
 (0)