aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/infer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/infer.rs')
-rw-r--r--crates/ra_hir/src/ty/infer.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 9244ff3cb..1057bbbec 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -1259,6 +1259,14 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1259 let inner_ty = self.infer_expr(*expr, &expectation); 1259 let inner_ty = self.infer_expr(*expr, &expectation);
1260 Ty::apply_one(TypeCtor::Ref(*mutability), inner_ty) 1260 Ty::apply_one(TypeCtor::Ref(*mutability), inner_ty)
1261 } 1261 }
1262 Expr::Box { expr } => {
1263 let inner_ty = self.infer_expr(*expr, &Expectation::none());
1264 if let Some(box_) = self.resolve_boxed_box() {
1265 Ty::apply_one(TypeCtor::Adt(box_), inner_ty)
1266 } else {
1267 Ty::Unknown
1268 }
1269 }
1262 Expr::UnaryOp { expr, op } => { 1270 Expr::UnaryOp { expr, op } => {
1263 let inner_ty = self.infer_expr(*expr, &Expectation::none()); 1271 let inner_ty = self.infer_expr(*expr, &Expectation::none());
1264 match op { 1272 match op {
@@ -1499,6 +1507,24 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1499 _ => None, 1507 _ => None,
1500 } 1508 }
1501 } 1509 }
1510
1511 fn resolve_boxed_box(&self) -> Option<AdtDef> {
1512 let boxed_box_path = Path {
1513 kind: PathKind::Abs,
1514 segments: vec![
1515 PathSegment { name: name::STD, args_and_bindings: None },
1516 PathSegment { name: name::BOXED_MOD, args_and_bindings: None },
1517 PathSegment { name: name::BOX_TYPE, args_and_bindings: None },
1518 ],
1519 };
1520
1521 match self.resolver.resolve_path_segments(self.db, &boxed_box_path).into_fully_resolved() {
1522 PerNs { types: Some(Def(ModuleDef::Struct(struct_))), .. } => {
1523 Some(AdtDef::Struct(struct_))
1524 }
1525 _ => None,
1526 }
1527 }
1502} 1528}
1503 1529
1504/// The ID of a type variable. 1530/// The ID of a type variable.