Skip to content

Commit

Permalink
Simplify base_expr
Browse files Browse the repository at this point in the history
Co-authored-by: Oli Scherer <[email protected]>
  • Loading branch information
sanxiyn and oli-obk authored Jan 28, 2021
1 parent d3c69a4 commit 899aae4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions compiler/rustc_passes/src/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,13 @@ fn should_explore(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool {
)
}

fn base_expr<'a>(expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> {
let mut current = expr;
fn base_expr<'a>(mut expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a>
loop {
match current.kind {
hir::ExprKind::Field(base, ..) => {
current = base;
}
_ => break,
match expr.kind {
hir::ExprKind::Field(base, ..) => expr = base,
_ => return expr,
}
}
current
}

struct MarkSymbolVisitor<'tcx> {
Expand Down

0 comments on commit 899aae4

Please sign in to comment.