about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-08-10 14:38:11 +0200
committerMazdak Farrokhzad <twingoow@gmail.com>2019-08-10 20:24:42 +0200
commit309bf2fcad3852c6675c38e14990f7a39276cb22 (patch)
treee9e110dd036cc9bb123278238209a9146c27cd15
parentc789e7a5cc156d6ceccab6581229c0433d284568 (diff)
downloadrust-309bf2fcad3852c6675c38e14990f7a39276cb22.tar.gz
rust-309bf2fcad3852c6675c38e14990f7a39276cb22.zip
lowering: extract lower_expr_range_closed
-rw-r--r--src/librustc/hir/lowering/expr.rs26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/librustc/hir/lowering/expr.rs b/src/librustc/hir/lowering/expr.rs
index acd0036ff66..6ae39d192c3 100644
--- a/src/librustc/hir/lowering/expr.rs
+++ b/src/librustc/hir/lowering/expr.rs
@@ -362,18 +362,8 @@ impl LoweringContext<'_> {
             ExprKind::Index(ref el, ref er) => {
                 hir::ExprKind::Index(P(self.lower_expr(el)), P(self.lower_expr(er)))
             }
-            // Desugar `<start>..=<end>` into `std::ops::RangeInclusive::new(<start>, <end>)`.
             ExprKind::Range(Some(ref e1), Some(ref e2), RangeLimits::Closed) => {
-                let id = self.next_id();
-                let e1 = self.lower_expr(e1);
-                let e2 = self.lower_expr(e2);
-                self.expr_call_std_assoc_fn(
-                    id,
-                    e.span,
-                    &[sym::ops, sym::RangeInclusive],
-                    "new",
-                    hir_vec![e1, e2],
-                )
+                self.lower_expr_range_closed(e.span, e1, e2)
             }
             ExprKind::Range(ref e1, ref e2, lims) => {
                 self.lower_expr_range(e.span, e1.as_deref(), e2.as_deref(), lims)
@@ -459,6 +449,20 @@ impl LoweringContext<'_> {
         }
     }
 
+    /// Desugar `<start>..=<end>` into `std::ops::RangeInclusive::new(<start>, <end>)`.
+    fn lower_expr_range_closed(&mut self, span: Span, e1: &Expr, e2: &Expr) -> hir::ExprKind {
+        let id = self.next_id();
+        let e1 = self.lower_expr(e1);
+        let e2 = self.lower_expr(e2);
+        self.expr_call_std_assoc_fn(
+            id,
+            span,
+            &[sym::ops, sym::RangeInclusive],
+            "new",
+            hir_vec![e1, e2],
+        )
+    }
+
     fn lower_expr_range(
         &mut self,
         span: Span,