aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/infer.rs
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-12-24 11:45:28 +0000
committerEdwin Cheng <[email protected]>2019-12-24 11:45:28 +0000
commit0edb5b4a501a66baa7db8ececf46135e6246f4de (patch)
treea65f9899f109d4df2c05069e037fe5dec0545d73 /crates/ra_hir_ty/src/infer.rs
parent60aa4d12f95477565d5b01f122d2c9dd845015b4 (diff)
Implement infer await from async func
Diffstat (limited to 'crates/ra_hir_ty/src/infer.rs')
-rw-r--r--crates/ra_hir_ty/src/infer.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs
index e97b81473..08c220cfe 100644
--- a/crates/ra_hir_ty/src/infer.rs
+++ b/crates/ra_hir_ty/src/infer.rs
@@ -37,8 +37,8 @@ use test_utils::tested_by;
37use super::{ 37use super::{
38 primitive::{FloatTy, IntTy}, 38 primitive::{FloatTy, IntTy},
39 traits::{Guidance, Obligation, ProjectionPredicate, Solution}, 39 traits::{Guidance, Obligation, ProjectionPredicate, Solution},
40 ApplicationTy, InEnvironment, ProjectionTy, Substs, TraitEnvironment, TraitRef, Ty, TypeCtor, 40 ApplicationTy, GenericPredicate, InEnvironment, ProjectionTy, Substs, TraitEnvironment,
41 TypeWalk, Uncertain, 41 TraitRef, Ty, TypeCtor, TypeWalk, Uncertain,
42}; 42};
43use crate::{db::HirDatabase, infer::diagnostics::InferenceDiagnostic}; 43use crate::{db::HirDatabase, infer::diagnostics::InferenceDiagnostic};
44 44
@@ -379,6 +379,19 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
379 ) -> Ty { 379 ) -> Ty {
380 match assoc_ty { 380 match assoc_ty {
381 Some(res_assoc_ty) => { 381 Some(res_assoc_ty) => {
382 // Fast path: Check if inner_ty is is `impl Trait` and contained input TypeAlias id
383 if let Ty::Opaque(ref predicates) = inner_ty {
384 for p in predicates.iter() {
385 if let GenericPredicate::Projection(projection) = p {
386 if projection.projection_ty.associated_ty == res_assoc_ty
387 && projection.ty != Ty::Unknown
388 {
389 return projection.ty.clone();
390 }
391 }
392 }
393 }
394
382 let ty = self.table.new_type_var(); 395 let ty = self.table.new_type_var();
383 let builder = Substs::build_for_def(self.db, res_assoc_ty) 396 let builder = Substs::build_for_def(self.db, res_assoc_ty)
384 .push(inner_ty) 397 .push(inner_ty)