about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-08-10 17:48:09 +0200
committerMazdak Farrokhzad <twingoow@gmail.com>2019-08-10 20:24:43 +0200
commit7f522155ddab6437ff472f3563cb42376df056ce (patch)
tree31f8fc344d38155cee758c7f7d15fd93b55eca4e
parent93570b02bdf0f4f21ed07865a6acce333134ef5b (diff)
downloadrust-7f522155ddab6437ff472f3563cb42376df056ce.tar.gz
rust-7f522155ddab6437ff472f3563cb42376df056ce.zip
lowering: move {lower_arm,arm} -> expr.rs
-rw-r--r--src/librustc/hir/lowering.rs25
-rw-r--r--src/librustc/hir/lowering/expr.rs29
2 files changed, 29 insertions, 25 deletions
diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs
index 8a39f412aaa..bf3a24de81b 100644
--- a/src/librustc/hir/lowering.rs
+++ b/src/librustc/hir/lowering.rs
@@ -1316,20 +1316,6 @@ impl<'a> LoweringContext<'a> {
         }
     }
 
-    fn lower_arm(&mut self, arm: &Arm) -> hir::Arm {
-        hir::Arm {
-            hir_id: self.next_id(),
-            attrs: self.lower_attrs(&arm.attrs),
-            pats: arm.pats.iter().map(|x| self.lower_pat(x)).collect(),
-            guard: match arm.guard {
-                Some(ref x) => Some(hir::Guard::If(P(self.lower_expr(x)))),
-                _ => None,
-            },
-            body: P(self.lower_expr(&arm.body)),
-            span: arm.span,
-        }
-    }
-
     /// Given an associated type constraint like one of these:
     ///
     /// ```
@@ -4472,17 +4458,6 @@ impl<'a> LoweringContext<'a> {
 
     // Helper methods for building HIR.
 
-    fn arm(&mut self, pats: hir::HirVec<P<hir::Pat>>, expr: P<hir::Expr>) -> hir::Arm {
-        hir::Arm {
-            hir_id: self.next_id(),
-            attrs: hir_vec![],
-            pats,
-            guard: None,
-            span: expr.span,
-            body: expr,
-        }
-    }
-
     fn stmt(&mut self, span: Span, node: hir::StmtKind) -> hir::Stmt {
         hir::Stmt { span, node, hir_id: self.next_id() }
     }
diff --git a/src/librustc/hir/lowering/expr.rs b/src/librustc/hir/lowering/expr.rs
index 57e7feaedc7..c76d714ffb4 100644
--- a/src/librustc/hir/lowering/expr.rs
+++ b/src/librustc/hir/lowering/expr.rs
@@ -436,6 +436,20 @@ impl LoweringContext<'_> {
         P(self.expr_call(e.span, from_err, hir_vec![e]))
     }
 
+    fn lower_arm(&mut self, arm: &Arm) -> hir::Arm {
+        hir::Arm {
+            hir_id: self.next_id(),
+            attrs: self.lower_attrs(&arm.attrs),
+            pats: arm.pats.iter().map(|x| self.lower_pat(x)).collect(),
+            guard: match arm.guard {
+                Some(ref x) => Some(hir::Guard::If(P(self.lower_expr(x)))),
+                _ => None,
+            },
+            body: P(self.lower_expr(&arm.body)),
+            span: arm.span,
+        }
+    }
+
     pub(super) fn make_async_expr(
         &mut self,
         capture_clause: CaptureBy,
@@ -1180,6 +1194,10 @@ impl LoweringContext<'_> {
         )
     }
 
+    // =========================================================================
+    // Helper methods for building HIR.
+    // =========================================================================
+
     /// Constructs a `true` or `false` literal expression.
     pub(super) fn expr_bool(&mut self, span: Span, val: bool) -> hir::Expr {
         let lit = Spanned { span, node: LitKind::Bool(val) };
@@ -1360,4 +1378,15 @@ impl LoweringContext<'_> {
             is_shorthand: false,
         }
     }
+
+    fn arm(&mut self, pats: hir::HirVec<P<hir::Pat>>, expr: P<hir::Expr>) -> hir::Arm {
+        hir::Arm {
+            hir_id: self.next_id(),
+            attrs: hir_vec![],
+            pats,
+            guard: None,
+            span: expr.span,
+            body: expr,
+        }
+    }
 }