diff options
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 7 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests/globs.rs | 20 | ||||
-rw-r--r-- | crates/ra_hir_def/src/visibility.rs | 7 |
3 files changed, 28 insertions, 6 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 63beaedc5..30771d510 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -378,12 +378,7 @@ where | |||
378 | .resolutions() | 378 | .resolutions() |
379 | // only keep visible names... | 379 | // only keep visible names... |
380 | .map(|(n, res)| { | 380 | .map(|(n, res)| { |
381 | ( | 381 | (n, res.filter_visibility(|v| v.visible_from_other_crate())) |
382 | n, | ||
383 | res.filter_visibility(|v| { | ||
384 | v.visible_from_def_map(&self.def_map, module_id) | ||
385 | }), | ||
386 | ) | ||
387 | }) | 382 | }) |
388 | .filter(|(_, res)| !res.is_none()) | 383 | .filter(|(_, res)| !res.is_none()) |
389 | .collect::<Vec<_>>(); | 384 | .collect::<Vec<_>>(); |
diff --git a/crates/ra_hir_def/src/nameres/tests/globs.rs b/crates/ra_hir_def/src/nameres/tests/globs.rs index 82d947b78..71fa0abe8 100644 --- a/crates/ra_hir_def/src/nameres/tests/globs.rs +++ b/crates/ra_hir_def/src/nameres/tests/globs.rs | |||
@@ -170,6 +170,26 @@ fn glob_across_crates() { | |||
170 | } | 170 | } |
171 | 171 | ||
172 | #[test] | 172 | #[test] |
173 | fn glob_privacy_across_crates() { | ||
174 | covers!(glob_across_crates); | ||
175 | let map = def_map( | ||
176 | " | ||
177 | //- /main.rs crate:main deps:test_crate | ||
178 | use test_crate::*; | ||
179 | |||
180 | //- /lib.rs crate:test_crate | ||
181 | pub struct Baz; | ||
182 | struct Foo; | ||
183 | ", | ||
184 | ); | ||
185 | assert_snapshot!(map, @r###" | ||
186 | ⋮crate | ||
187 | ⋮Baz: t v | ||
188 | "### | ||
189 | ); | ||
190 | } | ||
191 | |||
192 | #[test] | ||
173 | fn glob_enum() { | 193 | fn glob_enum() { |
174 | covers!(glob_enum); | 194 | covers!(glob_enum); |
175 | let map = def_map( | 195 | let map = def_map( |
diff --git a/crates/ra_hir_def/src/visibility.rs b/crates/ra_hir_def/src/visibility.rs index dccf2776e..a90ba7376 100644 --- a/crates/ra_hir_def/src/visibility.rs +++ b/crates/ra_hir_def/src/visibility.rs | |||
@@ -99,6 +99,13 @@ impl Visibility { | |||
99 | self.visible_from_def_map(&def_map, from_module.local_id) | 99 | self.visible_from_def_map(&def_map, from_module.local_id) |
100 | } | 100 | } |
101 | 101 | ||
102 | pub(crate) fn visible_from_other_crate(self) -> bool { | ||
103 | match self { | ||
104 | Visibility::Module(_) => false, | ||
105 | Visibility::Public => true, | ||
106 | } | ||
107 | } | ||
108 | |||
102 | pub(crate) fn visible_from_def_map( | 109 | pub(crate) fn visible_from_def_map( |
103 | self, | 110 | self, |
104 | def_map: &crate::nameres::CrateDefMap, | 111 | def_map: &crate::nameres::CrateDefMap, |