aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/body
diff options
context:
space:
mode:
authoroxalica <[email protected]>2019-11-29 06:49:12 +0000
committeroxalica <[email protected]>2019-11-29 06:49:12 +0000
commit2cb684bbce1c487b2efb5a8154afe66e4907ceac (patch)
treef93ef014cc82793949e8567634cec341ffc58d62 /crates/ra_hir_def/src/body
parent4992d2bf79e9da6db759eb8e1715f90f31ec7eb9 (diff)
Reduce variants of Expr
Diffstat (limited to 'crates/ra_hir_def/src/body')
-rw-r--r--crates/ra_hir_def/src/body/lower.rs19
1 files changed, 5 insertions, 14 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index d18964d54..be1eaa523 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -8,7 +8,7 @@ use hir_expand::{
8use ra_arena::Arena; 8use ra_arena::Arena;
9use ra_syntax::{ 9use ra_syntax::{
10 ast::{ 10 ast::{
11 self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, NameOwner, RangeOp, 11 self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, NameOwner,
12 TypeAscriptionOwner, 12 TypeAscriptionOwner,
13 }, 13 },
14 AstNode, AstPtr, 14 AstNode, AstPtr,
@@ -432,20 +432,11 @@ where
432 ast::Expr::RangeExpr(e) => { 432 ast::Expr::RangeExpr(e) => {
433 let lhs = e.start().map(|lhs| self.collect_expr(lhs)); 433 let lhs = e.start().map(|lhs| self.collect_expr(lhs));
434 let rhs = e.end().map(|rhs| self.collect_expr(rhs)); 434 let rhs = e.end().map(|rhs| self.collect_expr(rhs));
435 match (lhs, e.op_kind(), rhs) { 435 match e.op_kind() {
436 (None, _, None) => self.alloc_expr(Expr::RangeFull, syntax_ptr), 436 Some(range_type) => {
437 (Some(lhs), _, None) => self.alloc_expr(Expr::RangeFrom { lhs }, syntax_ptr), 437 self.alloc_expr(Expr::Range { lhs, rhs, range_type }, syntax_ptr)
438 (None, Some(RangeOp::Inclusive), Some(rhs)) => {
439 self.alloc_expr(Expr::RangeToInclusive { rhs }, syntax_ptr)
440 }
441 (Some(lhs), Some(RangeOp::Inclusive), Some(rhs)) => {
442 self.alloc_expr(Expr::RangeInclusive { lhs, rhs }, syntax_ptr)
443 }
444 // If RangeOp is missing, fallback to exclusive range.
445 (None, _, Some(rhs)) => self.alloc_expr(Expr::RangeTo { rhs }, syntax_ptr),
446 (Some(lhs), _, Some(rhs)) => {
447 self.alloc_expr(Expr::Range { lhs, rhs }, syntax_ptr)
448 } 438 }
439 None => self.alloc_expr(Expr::Missing, syntax_ptr),
449 } 440 }
450 } 441 }
451 442