Skip to content

Commit 5dc1196

Browse files
committed
Refactor away binding.is_pseudo_public().
1 parent 48a435a commit 5dc1196

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/librustc_resolve/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -885,10 +885,6 @@ impl<'a> NameBinding<'a> {
885885
}
886886
}
887887

888-
fn is_pseudo_public(&self) -> bool {
889-
self.pseudo_vis() == ty::Visibility::Public
890-
}
891-
892888
// We sometimes need to treat variants as `pub` for backwards compatibility
893889
fn pseudo_vis(&self) -> ty::Visibility {
894890
if self.is_variant() { ty::Visibility::Public } else { self.vis }

src/librustc_resolve/resolve_imports.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl<'a> Resolver<'a> {
168168
};
169169

170170
let is_disallowed_private_import = |binding: &NameBinding| {
171-
!allow_private_imports && !binding.is_pseudo_public() && binding.is_import()
171+
!allow_private_imports && binding.vis != ty::Visibility::Public && binding.is_import()
172172
};
173173

174174
if let Some(span) = record_used {
@@ -338,7 +338,7 @@ impl<'a> Resolver<'a> {
338338
};
339339

340340
// Define `new_binding` in `module`s glob importers.
341-
if new_binding.is_importable() && new_binding.is_pseudo_public() {
341+
if new_binding.vis == ty::Visibility::Public {
342342
for directive in module.glob_importers.borrow_mut().iter() {
343343
let imported_binding = self.import(new_binding, directive);
344344
let _ = self.try_define(directive.parent, name, ns, imported_binding);
@@ -656,9 +656,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
656656

657657
if let Some(Def::Trait(_)) = module.def {
658658
self.session.span_err(directive.span, "items in traits are not importable.");
659-
}
660-
661-
if module.def_id() == directive.parent.def_id() {
659+
return;
660+
} else if module.def_id() == directive.parent.def_id() {
662661
return;
663662
} else if let GlobImport { is_prelude: true } = directive.subclass {
664663
self.prelude = Some(module);
@@ -674,7 +673,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
674673
resolution.borrow().binding().map(|binding| (*name, binding))
675674
}).collect::<Vec<_>>();
676675
for ((name, ns), binding) in bindings {
677-
if binding.is_importable() && binding.is_pseudo_public() {
676+
if binding.pseudo_vis() == ty::Visibility::Public {
678677
let imported_binding = self.import(binding, directive);
679678
let _ = self.try_define(directive.parent, name, ns, imported_binding);
680679
}

0 commit comments

Comments
 (0)