Skip to content

Commit

Permalink
Simplify base_expr
Browse files Browse the repository at this point in the history
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
  • Loading branch information
sanxiyn and oli-obk committed 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
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.