diff options
Diffstat (limited to 'crates/ra_hir_def/src/body')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 331736cb2..d18964d54 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::{ | |||
8 | use ra_arena::Arena; | 8 | use ra_arena::Arena; |
9 | use ra_syntax::{ | 9 | use ra_syntax::{ |
10 | ast::{ | 10 | ast::{ |
11 | self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, NameOwner, | 11 | self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, NameOwner, RangeOp, |
12 | TypeAscriptionOwner, | 12 | TypeAscriptionOwner, |
13 | }, | 13 | }, |
14 | AstNode, AstPtr, | 14 | AstNode, AstPtr, |
@@ -429,10 +429,28 @@ where | |||
429 | let index = self.collect_expr_opt(e.index()); | 429 | let index = self.collect_expr_opt(e.index()); |
430 | self.alloc_expr(Expr::Index { base, index }, syntax_ptr) | 430 | self.alloc_expr(Expr::Index { base, index }, syntax_ptr) |
431 | } | 431 | } |
432 | ast::Expr::RangeExpr(e) => { | ||
433 | let lhs = e.start().map(|lhs| self.collect_expr(lhs)); | ||
434 | let rhs = e.end().map(|rhs| self.collect_expr(rhs)); | ||
435 | match (lhs, e.op_kind(), rhs) { | ||
436 | (None, _, None) => self.alloc_expr(Expr::RangeFull, syntax_ptr), | ||
437 | (Some(lhs), _, None) => self.alloc_expr(Expr::RangeFrom { lhs }, 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 | } | ||
449 | } | ||
450 | } | ||
432 | 451 | ||
433 | // FIXME implement HIR for these: | 452 | // FIXME implement HIR for these: |
434 | ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), | 453 | ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), |
435 | ast::Expr::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), | ||
436 | ast::Expr::MacroCall(e) => match self.expander.enter_expand(self.db, e) { | 454 | ast::Expr::MacroCall(e) => match self.expander.enter_expand(self.db, e) { |
437 | Some((mark, expansion)) => { | 455 | Some((mark, expansion)) => { |
438 | let id = self.collect_expr(expansion); | 456 | let id = self.collect_expr(expansion); |