diff options
Diffstat (limited to 'crates/ra_hir/src/ty/infer.rs')
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index a23daabc2..f5d8cd4b1 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs | |||
@@ -849,8 +849,19 @@ 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(match def { | ||
853 | // TODO add helper function | ||
854 | CallableDef::Function(f) => f.into(), | ||
855 | CallableDef::Struct(s) => s.into(), | ||
856 | CallableDef::EnumVariant(_e) => unimplemented!(), | ||
857 | }); | ||
858 | for predicate in generic_predicates.iter() { | ||
859 | let predicate = predicate.clone().subst(&a_ty.parameters); | ||
860 | if let Some(obligation) = Obligation::from_predicate(predicate) { | ||
861 | self.obligations.push(obligation); | ||
862 | } | ||
863 | } | ||
852 | // add obligation for trait implementation, if this is a trait method | 864 | // 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 { | 865 | match def { |
855 | CallableDef::Function(f) => { | 866 | CallableDef::Function(f) => { |
856 | if let Some(trait_) = f.parent_trait(self.db) { | 867 | if let Some(trait_) = f.parent_trait(self.db) { |
@@ -992,7 +1003,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
992 | (Vec::new(), Ty::Unknown) | 1003 | (Vec::new(), Ty::Unknown) |
993 | } | 1004 | } |
994 | }; | 1005 | }; |
995 | // FIXME register obligations from where clauses from the function | 1006 | self.register_obligations_for_call(&callee_ty); |
996 | let param_iter = param_tys.into_iter().chain(repeat(Ty::Unknown)); | 1007 | let param_iter = param_tys.into_iter().chain(repeat(Ty::Unknown)); |
997 | for (arg, param) in args.iter().zip(param_iter) { | 1008 | for (arg, param) in args.iter().zip(param_iter) { |
998 | self.infer_expr(*arg, &Expectation::has_type(param)); | 1009 | self.infer_expr(*arg, &Expectation::has_type(param)); |