Skip to content

Commit

Permalink
Auto merge of #119349 - zetanumbers:liveness-pass-refactor, r=WaffleL…
Browse files Browse the repository at this point in the history
…apkin

refactor(liveness): move walk_expr outside of every match branch
  • Loading branch information
bors committed Dec 28, 2023
2 parents 8e34642 + 4bb7a12 commit 928b3da
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions compiler/rustc_passes/src/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
if let Res::Local(_var_hir_id) = path.res {
self.add_live_node_for_node(expr.hir_id, ExprNode(expr.span, expr.hir_id));
}
intravisit::walk_expr(self, expr);
}
hir::ExprKind::Closure(closure) => {
// Interesting control flow (for loops can contain labeled
Expand All @@ -425,12 +424,10 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
}));
}
self.set_captures(expr.hir_id, call_caps);
intravisit::walk_expr(self, expr);
}

hir::ExprKind::Let(let_expr) => {
self.add_from_pat(let_expr.pat);
intravisit::walk_expr(self, expr);
}

// live nodes required for interesting control flow:
Expand All @@ -439,11 +436,9 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
| hir::ExprKind::Loop(..)
| hir::ExprKind::Yield(..) => {
self.add_live_node_for_node(expr.hir_id, ExprNode(expr.span, expr.hir_id));
intravisit::walk_expr(self, expr);
}
hir::ExprKind::Binary(op, ..) if op.node.is_lazy() => {
self.add_live_node_for_node(expr.hir_id, ExprNode(expr.span, expr.hir_id));
intravisit::walk_expr(self, expr);
}

// otherwise, live nodes are not required:
Expand Down Expand Up @@ -474,10 +469,9 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
| hir::ExprKind::Type(..)
| hir::ExprKind::Err(_)
| hir::ExprKind::Path(hir::QPath::TypeRelative(..))
| hir::ExprKind::Path(hir::QPath::LangItem(..)) => {
intravisit::walk_expr(self, expr);
}
| hir::ExprKind::Path(hir::QPath::LangItem(..)) => {}
}
intravisit::walk_expr(self, expr);
}
}

Expand Down

0 comments on commit 928b3da

Please sign in to comment.