diff options
Diffstat (limited to 'crates/ra_hir/src/ty/infer.rs')
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index a23daabc2..e79e5e223 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs | |||
@@ -849,8 +849,14 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
849 | fn register_obligations_for_call(&mut self, callable_ty: &Ty) { | 849 | fn register_obligations_for_call(&mut self, callable_ty: &Ty) { |
850 | if let Ty::Apply(a_ty) = callable_ty { | 850 | if let Ty::Apply(a_ty) = callable_ty { |
851 | if let TypeCtor::FnDef(def) = a_ty.ctor { | 851 | if let TypeCtor::FnDef(def) = a_ty.ctor { |
852 | let generic_predicates = self.db.generic_predicates(def.into()); | ||
853 | for predicate in generic_predicates.iter() { | ||
854 | let predicate = predicate.clone().subst(&a_ty.parameters); | ||
855 | if let Some(obligation) = Obligation::from_predicate(predicate) { | ||
856 | self.obligations.push(obligation); | ||
857 | } | ||
858 | } | ||
852 | // add obligation for trait implementation, if this is a trait method | 859 | // add obligation for trait implementation, if this is a trait method |
853 | // FIXME also register obligations from where clauses from the trait or impl and method | ||
854 | match def { | 860 | match def { |
855 | CallableDef::Function(f) => { | 861 | CallableDef::Function(f) => { |
856 | if let Some(trait_) = f.parent_trait(self.db) { | 862 | if let Some(trait_) = f.parent_trait(self.db) { |
@@ -992,7 +998,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
992 | (Vec::new(), Ty::Unknown) | 998 | (Vec::new(), Ty::Unknown) |
993 | } | 999 | } |
994 | }; | 1000 | }; |
995 | // FIXME register obligations from where clauses from the function | 1001 | self.register_obligations_for_call(&callee_ty); |
996 | let param_iter = param_tys.into_iter().chain(repeat(Ty::Unknown)); | 1002 | let param_iter = param_tys.into_iter().chain(repeat(Ty::Unknown)); |
997 | for (arg, param) in args.iter().zip(param_iter) { | 1003 | for (arg, param) in args.iter().zip(param_iter) { |
998 | self.infer_expr(*arg, &Expectation::has_type(param)); | 1004 | self.infer_expr(*arg, &Expectation::has_type(param)); |