about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSeo Sanghyeon <sanxiyn@gmail.com>2021-01-29 01:44:15 +0900
committerGitHub <noreply@github.com>2021-01-29 01:44:15 +0900
commit899aae465eb4ef295dc1eeb2603f744568e0768c (patch)
tree1b7f4f7925095972dd280cafe5239b93e6a9bbfe
parentd3c69a4c0dd98af2611b7553d1a65afef6a6ccb0 (diff)
downloadrust-899aae465eb4ef295dc1eeb2603f744568e0768c.tar.gz
rust-899aae465eb4ef295dc1eeb2603f744568e0768c.zip
Simplify base_expr
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
-rw-r--r--compiler/rustc_passes/src/dead.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs
index a4798b9ae1f..3902557e9b5 100644
--- a/compiler/rustc_passes/src/dead.rs
+++ b/compiler/rustc_passes/src/dead.rs
@@ -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> {