.resolutions()
// only keep visible names...
.map(|(n, res)| {
- (
- n,
- res.filter_visibility(|v| {
- v.visible_from_def_map(&self.def_map, module_id)
- }),
- )
+ (n, res.filter_visibility(|v| v.visible_from_other_crate()))
})
.filter(|(_, res)| !res.is_none())
.collect::<Vec<_>>();
);
}
+#[test]
+fn glob_privacy_across_crates() {
+ covers!(glob_across_crates);
+ let map = def_map(
+ "
+ //- /main.rs crate:main deps:test_crate
+ use test_crate::*;
+
+ //- /lib.rs crate:test_crate
+ pub struct Baz;
+ struct Foo;
+ ",
+ );
+ assert_snapshot!(map, @r###"
+ ⋮crate
+ ⋮Baz: t v
+ "###
+ );
+}
+
#[test]
fn glob_enum() {
covers!(glob_enum);
self.visible_from_def_map(&def_map, from_module.local_id)
}
+ pub(crate) fn visible_from_other_crate(self) -> bool {
+ match self {
+ Visibility::Module(_) => false,
+ Visibility::Public => true,
+ }
+ }
+
pub(crate) fn visible_from_def_map(
self,
def_map: &crate::nameres::CrateDefMap,