diff options
author | cynecx <[email protected]> | 2021-03-20 18:48:35 +0000 |
---|---|---|
committer | cynecx <[email protected]> | 2021-03-20 18:50:55 +0000 |
commit | ac2a831b2e61a5a3ef5edd20791b4b2db48402b2 (patch) | |
tree | eddd897a54d750390c358ae8031e65ae0f8a372f /crates | |
parent | 66d295d72df72640573522df527deb90abc94fcd (diff) |
hir_ty: iterate_method_candidates_for_self_ty pass `visible_from_module` down to `iterate_inherent_methods`
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_ty/src/method_resolution.rs | 7 |
1 files changed, 6 insertions, 1 deletions
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( | |||
420 | env, | 420 | env, |
421 | krate, | 421 | krate, |
422 | traits_in_scope, | 422 | traits_in_scope, |
423 | visible_from_module, | ||
423 | name, | 424 | name, |
424 | callback, | 425 | callback, |
425 | ) | 426 | ) |
@@ -537,10 +538,12 @@ fn iterate_method_candidates_for_self_ty( | |||
537 | env: Arc<TraitEnvironment>, | 538 | env: Arc<TraitEnvironment>, |
538 | krate: CrateId, | 539 | krate: CrateId, |
539 | traits_in_scope: &FxHashSet<TraitId>, | 540 | traits_in_scope: &FxHashSet<TraitId>, |
541 | visible_from_module: Option<ModuleId>, | ||
540 | name: Option<&Name>, | 542 | name: Option<&Name>, |
541 | mut callback: &mut dyn FnMut(&Ty, AssocItemId) -> bool, | 543 | mut callback: &mut dyn FnMut(&Ty, AssocItemId) -> bool, |
542 | ) -> bool { | 544 | ) -> bool { |
543 | if iterate_inherent_methods(self_ty, db, name, None, krate, None, &mut callback) { | 545 | if iterate_inherent_methods(self_ty, db, name, None, krate, visible_from_module, &mut callback) |
546 | { | ||
544 | return true; | 547 | return true; |
545 | } | 548 | } |
546 | iterate_trait_method_candidates(self_ty, db, env, krate, traits_in_scope, name, None, callback) | 549 | iterate_trait_method_candidates(self_ty, db, env, krate, traits_in_scope, name, None, callback) |
@@ -577,6 +580,8 @@ fn iterate_trait_method_candidates( | |||
577 | // iteration | 580 | // iteration |
578 | let mut known_implemented = false; | 581 | let mut known_implemented = false; |
579 | for (_name, item) in data.items.iter() { | 582 | for (_name, item) in data.items.iter() { |
583 | // Don't pass a `visible_from_module` down to `is_valid_candidate`, | ||
584 | // since only inherent methods should be included into visibility checking. | ||
580 | if !is_valid_candidate(db, name, receiver_ty, *item, self_ty, None) { | 585 | if !is_valid_candidate(db, name, receiver_ty, *item, self_ty, None) { |
581 | continue; | 586 | continue; |
582 | } | 587 | } |