]> git.lizzy.rs Git - rust.git/blobdiff - crates/hir/src/semantics.rs
Record method call substs and use them in call info
[rust.git] / crates / hir / src / semantics.rs
index 1b5064b5a20d6203149ec7ca935db60c25596d6a..d65dd7df08de2ef28e86f0474a0692cd3ae1ad73 100644 (file)
@@ -11,7 +11,7 @@
     AsMacroCall, FunctionId, TraitId, VariantId,
 };
 use hir_expand::{name::AsName, ExpansionInfo};
-use hir_ty::associated_type_shorthand_candidates;
+use hir_ty::{associated_type_shorthand_candidates, Interner};
 use itertools::Itertools;
 use rustc_hash::{FxHashMap, FxHashSet};
 use syntax::{
@@ -501,14 +501,12 @@ fn type_of_self(&self, param: &ast::SelfParam) -> Option<Type> {
     }
 
     fn resolve_method_call(&self, call: &ast::MethodCallExpr) -> Option<FunctionId> {
-        self.analyze(call.syntax()).resolve_method_call(self.db, call)
+        self.analyze(call.syntax()).resolve_method_call(self.db, call).map(|(id, _)| id)
     }
 
     fn resolve_method_call_as_callable(&self, call: &ast::MethodCallExpr) -> Option<Callable> {
-        // FIXME: this erases Substs, we should instead record the correct
-        // substitution during inference and use that
-        let func = self.resolve_method_call(call)?;
-        let ty = hir_ty::TyBuilder::value_ty(self.db, func.into()).fill_with_unknown().build();
+        let (func, subst) = self.analyze(call.syntax()).resolve_method_call(self.db, call)?;
+        let ty = self.db.value_ty(func.into()).substitute(&Interner, &subst);
         let resolver = self.analyze(call.syntax()).resolver;
         let ty = Type::new_with_resolver(self.db, &resolver, ty)?;
         let mut res = ty.as_callable(self.db)?;