aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty.rs')
-rw-r--r--crates/ra_hir/src/ty.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 31ea45706..e2c7884b5 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -1395,7 +1395,9 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1395 for &pat in &arm.pats { 1395 for &pat in &arm.pats {
1396 let _pat_ty = self.infer_pat(pat, &input_ty); 1396 let _pat_ty = self.infer_pat(pat, &input_ty);
1397 } 1397 }
1398 // TODO type the guard 1398 if let Some(guard_expr) = arm.guard {
1399 self.infer_expr(guard_expr, &Expectation::has_type(Ty::Bool));
1400 }
1399 self.infer_expr(arm.expr, &expected); 1401 self.infer_expr(arm.expr, &expected);
1400 } 1402 }
1401 1403
@@ -1468,9 +1470,17 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1468 cast_ty 1470 cast_ty
1469 } 1471 }
1470 Expr::Ref { expr, mutability } => { 1472 Expr::Ref { expr, mutability } => {
1471 // TODO pass the expectation down 1473 let expectation = if let Ty::Ref(ref subty, expected_mutability) = expected.ty {
1472 let inner_ty = self.infer_expr(*expr, &Expectation::none()); 1474 if expected_mutability == Mutability::Mut && *mutability == Mutability::Shared {
1475 // TODO: throw type error - expected mut reference but found shared ref,
1476 // which cannot be coerced
1477 }
1478 Expectation::has_type((**subty).clone())
1479 } else {
1480 Expectation::none()
1481 };
1473 // TODO reference coercions etc. 1482 // TODO reference coercions etc.
1483 let inner_ty = self.infer_expr(*expr, &expectation);
1474 Ty::Ref(Arc::new(inner_ty), *mutability) 1484 Ty::Ref(Arc::new(inner_ty), *mutability)
1475 } 1485 }
1476 Expr::UnaryOp { expr, op } => { 1486 Expr::UnaryOp { expr, op } => {