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.rs42
1 files changed, 40 insertions, 2 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 6eae595a9..a82dff711 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -1114,8 +1114,24 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1114 .unwrap_or(Ty::Unknown); 1114 .unwrap_or(Ty::Unknown);
1115 self.insert_type_vars(ty) 1115 self.insert_type_vars(ty)
1116 } 1116 }
1117 Expr::Await { .. } => { 1117 Expr::Await { expr } => {
1118 Ty::Unknown 1118 let inner_ty = self.infer_expr(*expr, &Expectation::none());
1119 let ty = match self.resolve_future_future_output() {
1120 Some(future_future_output_alias) => {
1121 let ty = self.new_type_var();
1122 let projection = ProjectionPredicate {
1123 ty: ty.clone(),
1124 projection_ty: ProjectionTy {
1125 associated_ty: future_future_output_alias,
1126 parameters: vec![inner_ty].into(),
1127 },
1128 };
1129 self.obligations.push(Obligation::Projection(projection));
1130 self.resolve_ty_as_possible(&mut vec![], ty)
1131 }
1132 None => Ty::Unknown,
1133 };
1134 ty
1119 } 1135 }
1120 Expr::Try { expr } => { 1136 Expr::Try { expr } => {
1121 let inner_ty = self.infer_expr(*expr, &Expectation::none()); 1137 let inner_ty = self.infer_expr(*expr, &Expectation::none());
@@ -1371,6 +1387,28 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1371 _ => None, 1387 _ => None,
1372 } 1388 }
1373 } 1389 }
1390
1391 fn resolve_future_future_output(&self) -> Option<TypeAlias> {
1392 let future_future_path = Path {
1393 kind: PathKind::Abs,
1394 segments: vec![
1395 PathSegment { name: name::STD, args_and_bindings: None },
1396 PathSegment { name: name::FUTURE_MOD, args_and_bindings: None },
1397 PathSegment { name: name::FUTURE_TYPE, args_and_bindings: None },
1398 ],
1399 };
1400
1401 match self
1402 .resolver
1403 .resolve_path_segments(self.db, &future_future_path)
1404 .into_fully_resolved()
1405 {
1406 PerNs { types: Some(Def(Trait(trait_))), .. } => {
1407 Some(trait_.associated_type_by_name(self.db, name::OUTPUT)?)
1408 }
1409 _ => None,
1410 }
1411 }
1374} 1412}
1375 1413
1376/// The ID of a type variable. 1414/// The ID of a type variable.