]> git.lizzy.rs Git - rust.git/commitdiff
Paper over #8931 a bit more
authorFlorian Diebold <flodiebold@gmail.com>
Sun, 23 May 2021 11:00:14 +0000 (13:00 +0200)
committerFlorian Diebold <flodiebold@gmail.com>
Sun, 23 May 2021 11:00:14 +0000 (13:00 +0200)
The problem was the skipping of binders in
`resolve_method_call_as_callable`; this still doesn't use the _correct_
substitution, but at least it doesn't return a type with free variables
in it.

Fixes #8931.

crates/hir/src/semantics.rs
crates/ide_completion/src/completions/dot.rs

index 38bd376bc08d71aec5ba8c2d9b55ebe304b83097..1b5064b5a20d6203149ec7ca935db60c25596d6a 100644 (file)
@@ -505,9 +505,10 @@ fn resolve_method_call(&self, call: &ast::MethodCallExpr) -> Option<FunctionId>
     }
 
     fn resolve_method_call_as_callable(&self, call: &ast::MethodCallExpr) -> Option<Callable> {
-        // FIXME: this erases Substs
+        // 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, _) = self.db.value_ty(func.into()).into_value_and_skipped_binders();
+        let ty = hir_ty::TyBuilder::value_ty(self.db, func.into()).fill_with_unknown().build();
         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)?;
index 1bff559365be9bc72595c741b591295f9fb023a0..fd97387437be4cda7b81463f03df62d40a233465 100644 (file)
@@ -480,6 +480,7 @@ fn f(&mut self, v: Foo) {
 }
         "#,
             expect![[r#"
+                me foo() fn(&self) -> &[u8]
             "#]],
         );
     }