about summary refs log tree commit diff
path: root/compiler/rustc_passes/src
diff options
context:
space:
mode:
authorDing Xiang Fei <dingxiangfei2009@protonmail.ch>2022-07-05 23:31:18 +0200
committerDing Xiang Fei <dingxiangfei2009@protonmail.ch>2022-07-11 23:20:37 +0200
commit1cd30e7b32df602cf455d34ff8042079b8e082a3 (patch)
tree8e1718add47e77e23a2895a900767a5e44f38f25 /compiler/rustc_passes/src
parent6c529ded8674b89c46052da92399227c3b764c6a (diff)
downloadrust-1cd30e7b32df602cf455d34ff8042079b8e082a3.tar.gz
rust-1cd30e7b32df602cf455d34ff8042079b8e082a3.zip
move else block into the `Local` struct
Diffstat (limited to 'compiler/rustc_passes/src')
-rw-r--r--compiler/rustc_passes/src/check_attr.rs2
-rw-r--r--compiler/rustc_passes/src/hir_stats.rs4
-rw-r--r--compiler/rustc_passes/src/liveness.rs14
3 files changed, 10 insertions, 10 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs
index f78c0f4f545..d0723c68a77 100644
--- a/compiler/rustc_passes/src/check_attr.rs
+++ b/compiler/rustc_passes/src/check_attr.rs
@@ -2311,7 +2311,7 @@ impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> {
 
     fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt<'tcx>) {
         // When checking statements ignore expressions, they will be checked later.
-        if let hir::StmtKind::Local(ref l, _) = stmt.kind {
+        if let hir::StmtKind::Local(ref l) = stmt.kind {
             self.check_attributes(l.hir_id, stmt.span, Target::Statement, None);
         }
         intravisit::walk_stmt(self, stmt)
diff --git a/compiler/rustc_passes/src/hir_stats.rs b/compiler/rustc_passes/src/hir_stats.rs
index d8e97e5adef..a3be827a7cc 100644
--- a/compiler/rustc_passes/src/hir_stats.rs
+++ b/compiler/rustc_passes/src/hir_stats.rs
@@ -131,9 +131,9 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
         hir_visit::walk_foreign_item(self, i)
     }
 
-    fn visit_local(&mut self, l: &'v hir::Local<'v>, e: Option<&'v hir::Block<'v>>) {
+    fn visit_local(&mut self, l: &'v hir::Local<'v>) {
         self.record("Local", Id::Node(l.hir_id), l);
-        hir_visit::walk_local(self, l, e)
+        hir_visit::walk_local(self, l)
     }
 
     fn visit_block(&mut self, b: &'v hir::Block<'v>) {
diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs
index f125f107fe2..eed3e1579a2 100644
--- a/compiler/rustc_passes/src/liveness.rs
+++ b/compiler/rustc_passes/src/liveness.rs
@@ -366,12 +366,12 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
         lsets.warn_about_unused_args(body, entry_ln);
     }
 
-    fn visit_local(&mut self, local: &'tcx hir::Local<'tcx>, els: Option<&'tcx hir::Block<'tcx>>) {
+    fn visit_local(&mut self, local: &'tcx hir::Local<'tcx>) {
         self.add_from_pat(&local.pat);
-        if els.is_some() {
+        if local.els.is_some() {
             self.add_live_node_for_node(local.hir_id, ExprNode(local.span, local.hir_id));
         }
-        intravisit::walk_local(self, local, els);
+        intravisit::walk_local(self, local);
     }
 
     fn visit_arm(&mut self, arm: &'tcx hir::Arm<'tcx>) {
@@ -788,7 +788,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
 
     fn propagate_through_stmt(&mut self, stmt: &hir::Stmt<'_>, succ: LiveNode) -> LiveNode {
         match stmt.kind {
-            hir::StmtKind::Local(ref local, els) => {
+            hir::StmtKind::Local(ref local) => {
                 // Note: we mark the variable as defined regardless of whether
                 // there is an initializer.  Initially I had thought to only mark
                 // the live variable as defined if it was initialized, and then we
@@ -803,7 +803,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
                 // initialization, which is mildly more complex than checking
                 // once at the func header but otherwise equivalent.
 
-                if let Some(els) = els {
+                if let Some(els) = local.els {
                     // Eventually, `let pat: ty = init else { els };` is mostly equivalent to
                     // `let (bindings, ...) = match init { pat => (bindings, ...), _ => els };`
                     // except that extended lifetime applies at the `init` location.
@@ -1341,14 +1341,14 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
 // Checking for error conditions
 
 impl<'a, 'tcx> Visitor<'tcx> for Liveness<'a, 'tcx> {
-    fn visit_local(&mut self, local: &'tcx hir::Local<'tcx>, els: Option<&'tcx hir::Block<'tcx>>) {
+    fn visit_local(&mut self, local: &'tcx hir::Local<'tcx>) {
         self.check_unused_vars_in_pat(&local.pat, None, |spans, hir_id, ln, var| {
             if local.init.is_some() {
                 self.warn_about_dead_assign(spans, hir_id, ln, var);
             }
         });
 
-        intravisit::walk_local(self, local, els);
+        intravisit::walk_local(self, local);
     }
 
     fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) {