From ac2a831b2e61a5a3ef5edd20791b4b2db48402b2 Mon Sep 17 00:00:00 2001 From: cynecx Date: Sat, 20 Mar 2021 19:48:35 +0100 Subject: hir_ty: iterate_method_candidates_for_self_ty pass `visible_from_module` down to `iterate_inherent_methods` --- crates/hir_ty/src/method_resolution.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 6c34982a1..80e7b7b79 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs @@ -420,6 +420,7 @@ fn iterate_method_candidates_impl( env, krate, traits_in_scope, + visible_from_module, name, callback, ) @@ -537,10 +538,12 @@ fn iterate_method_candidates_for_self_ty( env: Arc, krate: CrateId, traits_in_scope: &FxHashSet, + visible_from_module: Option, name: Option<&Name>, mut callback: &mut dyn FnMut(&Ty, AssocItemId) -> bool, ) -> bool { - if iterate_inherent_methods(self_ty, db, name, None, krate, None, &mut callback) { + if iterate_inherent_methods(self_ty, db, name, None, krate, visible_from_module, &mut callback) + { return true; } iterate_trait_method_candidates(self_ty, db, env, krate, traits_in_scope, name, None, callback) @@ -577,6 +580,8 @@ fn iterate_trait_method_candidates( // iteration let mut known_implemented = false; for (_name, item) in data.items.iter() { + // Don't pass a `visible_from_module` down to `is_valid_candidate`, + // since only inherent methods should be included into visibility checking. if !is_valid_candidate(db, name, receiver_ty, *item, self_ty, None) { continue; } -- cgit v1.2.3