diff options
Diffstat (limited to 'crates/ra_hir_ty/src/infer')
-rw-r--r-- | crates/ra_hir_ty/src/infer/expr.rs | 19 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/infer/path.rs | 9 |
2 files changed, 20 insertions, 8 deletions
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index 3af05394c..d6a17e469 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs | |||
@@ -569,12 +569,19 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
569 | ) -> Ty { | 569 | ) -> Ty { |
570 | let receiver_ty = self.infer_expr(receiver, &Expectation::none()); | 570 | let receiver_ty = self.infer_expr(receiver, &Expectation::none()); |
571 | let canonicalized_receiver = self.canonicalizer().canonicalize_ty(receiver_ty.clone()); | 571 | let canonicalized_receiver = self.canonicalizer().canonicalize_ty(receiver_ty.clone()); |
572 | let resolved = method_resolution::lookup_method( | 572 | |
573 | &canonicalized_receiver.value, | 573 | let traits_in_scope = self.resolver.traits_in_scope(self.db); |
574 | self.db, | 574 | |
575 | method_name, | 575 | let resolved = self.resolver.krate().and_then(|krate| { |
576 | &self.resolver, | 576 | method_resolution::lookup_method( |
577 | ); | 577 | &canonicalized_receiver.value, |
578 | self.db, | ||
579 | self.trait_env.clone(), | ||
580 | krate, | ||
581 | &traits_in_scope, | ||
582 | method_name, | ||
583 | ) | ||
584 | }); | ||
578 | let (derefed_receiver_ty, method_ty, def_generics) = match resolved { | 585 | let (derefed_receiver_ty, method_ty, def_generics) = match resolved { |
579 | Some((ty, func)) => { | 586 | Some((ty, func)) => { |
580 | let ty = canonicalized_receiver.decanonicalize_ty(ty); | 587 | let ty = canonicalized_receiver.decanonicalize_ty(ty); |
diff --git a/crates/ra_hir_ty/src/infer/path.rs b/crates/ra_hir_ty/src/infer/path.rs index ffd358367..2c1d4831d 100644 --- a/crates/ra_hir_ty/src/infer/path.rs +++ b/crates/ra_hir_ty/src/infer/path.rs | |||
@@ -11,7 +11,7 @@ use hir_expand::name::Name; | |||
11 | 11 | ||
12 | use crate::{db::HirDatabase, method_resolution, Substs, Ty, TypeWalk, ValueTyDefId}; | 12 | use crate::{db::HirDatabase, method_resolution, Substs, Ty, TypeWalk, ValueTyDefId}; |
13 | 13 | ||
14 | use super::{ExprOrPatId, InferenceContext, TraitRef}; | 14 | use super::{ExprOrPatId, InferenceContext, TraitEnvironment, TraitRef}; |
15 | 15 | ||
16 | impl<'a, D: HirDatabase> InferenceContext<'a, D> { | 16 | impl<'a, D: HirDatabase> InferenceContext<'a, D> { |
17 | pub(super) fn infer_path( | 17 | pub(super) fn infer_path( |
@@ -193,11 +193,16 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
193 | } | 193 | } |
194 | 194 | ||
195 | let canonical_ty = self.canonicalizer().canonicalize_ty(ty.clone()); | 195 | let canonical_ty = self.canonicalizer().canonicalize_ty(ty.clone()); |
196 | let env = TraitEnvironment::lower(self.db, &self.resolver); | ||
197 | let krate = self.resolver.krate()?; | ||
198 | let traits_in_scope = self.resolver.traits_in_scope(self.db); | ||
196 | 199 | ||
197 | method_resolution::iterate_method_candidates( | 200 | method_resolution::iterate_method_candidates( |
198 | &canonical_ty.value, | 201 | &canonical_ty.value, |
199 | self.db, | 202 | self.db, |
200 | &self.resolver.clone(), | 203 | env, |
204 | krate, | ||
205 | &traits_in_scope, | ||
201 | Some(name), | 206 | Some(name), |
202 | method_resolution::LookupMode::Path, | 207 | method_resolution::LookupMode::Path, |
203 | move |_ty, item| { | 208 | move |_ty, item| { |