From 759cb07891d6c9583095d7a1423619b36bc3d547 Mon Sep 17 00:00:00 2001 From: cynecx Date: Mon, 31 May 2021 20:04:18 +0200 Subject: hir_ty: use correct receiver_ty in method resolution --- crates/hir_ty/src/infer/expr.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'crates/hir_ty/src/infer') diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 41ef45326..f73bf43b2 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -890,7 +890,7 @@ impl<'a> InferenceContext<'a> { method_name, ) }); - let (derefed_receiver_ty, method_ty, substs) = match resolved { + let (receiver_ty, method_ty, substs) = match resolved { Some((ty, func)) => { let ty = canonicalized_receiver.decanonicalize_ty(ty); let generics = generics(self.db.upcast(), func.into()); @@ -916,16 +916,7 @@ impl<'a> InferenceContext<'a> { } None => (self.err_ty(), Vec::new(), self.err_ty()), }; - // Apply autoref so the below unification works correctly - // FIXME: return correct autorefs from lookup_method - let actual_receiver_ty = match self.resolve_ty_shallow(&expected_receiver_ty).as_reference() - { - Some((_, lifetime, mutability)) => { - TyKind::Ref(mutability, lifetime, derefed_receiver_ty).intern(&Interner) - } - _ => derefed_receiver_ty, - }; - self.unify(&expected_receiver_ty, &actual_receiver_ty); + self.unify(&expected_receiver_ty, &receiver_ty); self.check_call_arguments(args, ¶m_tys); self.normalize_associated_types_in(ret_ty) -- cgit v1.2.3