Simplify base_expr

Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
This commit is contained in:
Seo Sanghyeon 2021-01-29 01:44:15 +09:00 committed by GitHub
parent d3c69a4c0d
commit 899aae465e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 8 deletions

View File

@ -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> {