diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 6383a467ebc..544312f6fc3 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -2564,7 +2564,7 @@ impl Type { krate: Crate, traits_in_scope: &FxHashSet, name: Option<&Name>, - mut callback: impl FnMut(&Ty, Function) -> Option, + mut callback: impl FnMut(Type, Function) -> Option, ) -> Option { let _p = profile::span("iterate_method_candidates"); let mut slot = None; @@ -2575,7 +2575,7 @@ impl Type { name, &mut |ty, assoc_item_id| match assoc_item_id { AssocItemId::FunctionId(it) => { - slot = callback(ty, it.into()); + slot = callback(self.derived(ty.clone()), it.into()); slot.is_some() } AssocItemId::ConstId(_) | AssocItemId::TypeAliasId(_) => false, @@ -2620,7 +2620,7 @@ impl Type { krate: Crate, traits_in_scope: &FxHashSet, name: Option<&Name>, - mut callback: impl FnMut(&Ty, AssocItem) -> Option, + mut callback: impl FnMut(Type, AssocItem) -> Option, ) -> Option { let _p = profile::span("iterate_path_candidates"); let mut slot = None; @@ -2630,7 +2630,7 @@ impl Type { traits_in_scope, name, &mut |ty, assoc_item_id| { - slot = callback(ty, assoc_item_id.into()); + slot = callback(self.derived(ty.clone()), assoc_item_id.into()); slot.is_some() }, ); diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 0bd1d30bbfb..9b789b5fa2f 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs @@ -410,7 +410,7 @@ pub enum LookupMode { // This would be nicer if it just returned an iterator, but that runs into // lifetime problems, because we need to borrow temp `CrateImplDefs`. // FIXME add a context type here? -pub fn iterate_method_candidates( +pub fn iterate_method_candidates( ty: &Canonical, db: &dyn HirDatabase, env: Arc,