aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/infer
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/infer')
-rw-r--r--crates/ra_hir_ty/src/infer/expr.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs
index 2f9ca4bbb..a00aa426a 100644
--- a/crates/ra_hir_ty/src/infer/expr.rs
+++ b/crates/ra_hir_ty/src/infer/expr.rs
@@ -415,6 +415,47 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
415 } 415 }
416 _ => Ty::Unknown, 416 _ => Ty::Unknown,
417 }, 417 },
418 Expr::RangeFull => match self.resolve_range_full() {
419 Some(adt) => Ty::simple(TypeCtor::Adt(adt)),
420 None => Ty::Unknown,
421 },
422 Expr::Range { lhs, rhs } => {
423 let lhs_ty = self.infer_expr(*lhs, &Expectation::none());
424 let rhs_ty = self.infer_expr(*rhs, &Expectation::has_type(lhs_ty));
425 match self.resolve_range() {
426 Some(adt) => Ty::apply_one(TypeCtor::Adt(adt), rhs_ty),
427 None => Ty::Unknown,
428 }
429 }
430 Expr::RangeInclusive { lhs, rhs } => {
431 let lhs_ty = self.infer_expr(*lhs, &Expectation::none());
432 let rhs_ty = self.infer_expr(*rhs, &Expectation::has_type(lhs_ty));
433 match self.resolve_range_inclusive() {
434 Some(adt) => Ty::apply_one(TypeCtor::Adt(adt), rhs_ty),
435 None => Ty::Unknown,
436 }
437 }
438 Expr::RangeFrom { lhs } => {
439 let ty = self.infer_expr(*lhs, &Expectation::none());
440 match self.resolve_range_from() {
441 Some(adt) => Ty::apply_one(TypeCtor::Adt(adt), ty),
442 None => Ty::Unknown,
443 }
444 }
445 Expr::RangeTo { rhs } => {
446 let ty = self.infer_expr(*rhs, &Expectation::none());
447 match self.resolve_range_to() {
448 Some(adt) => Ty::apply_one(TypeCtor::Adt(adt), ty),
449 None => Ty::Unknown,
450 }
451 }
452 Expr::RangeToInclusive { rhs } => {
453 let ty = self.infer_expr(*rhs, &Expectation::none());
454 match self.resolve_range_to_inclusive() {
455 Some(adt) => Ty::apply_one(TypeCtor::Adt(adt), ty),
456 None => Ty::Unknown,
457 }
458 }
418 Expr::Index { base, index } => { 459 Expr::Index { base, index } => {
419 let _base_ty = self.infer_expr(*base, &Expectation::none()); 460 let _base_ty = self.infer_expr(*base, &Expectation::none());
420 let _index_ty = self.infer_expr(*index, &Expectation::none()); 461 let _index_ty = self.infer_expr(*index, &Expectation::none());