mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
Refactor away binding.is_pseudo_public().
This commit is contained in:
@@ -885,10 +885,6 @@ fn def(&self) -> Option<Def> {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_pseudo_public(&self) -> bool {
|
||||
self.pseudo_vis() == ty::Visibility::Public
|
||||
}
|
||||
|
||||
// We sometimes need to treat variants as `pub` for backwards compatibility
|
||||
fn pseudo_vis(&self) -> ty::Visibility {
|
||||
if self.is_variant() { ty::Visibility::Public } else { self.vis }
|
||||
|
||||
@@ -168,7 +168,7 @@ pub fn resolve_name_in_module(&mut self,
|
||||
};
|
||||
|
||||
let is_disallowed_private_import = |binding: &NameBinding| {
|
||||
!allow_private_imports && !binding.is_pseudo_public() && binding.is_import()
|
||||
!allow_private_imports && binding.vis != ty::Visibility::Public && binding.is_import()
|
||||
};
|
||||
|
||||
if let Some(span) = record_used {
|
||||
@@ -338,7 +338,7 @@ fn update_resolution<T, F>(&mut self, module: Module<'a>, name: Name, ns: Namesp
|
||||
};
|
||||
|
||||
// Define `new_binding` in `module`s glob importers.
|
||||
if new_binding.is_importable() && new_binding.is_pseudo_public() {
|
||||
if new_binding.vis == ty::Visibility::Public {
|
||||
for directive in module.glob_importers.borrow_mut().iter() {
|
||||
let imported_binding = self.import(new_binding, directive);
|
||||
let _ = self.try_define(directive.parent, name, ns, imported_binding);
|
||||
@@ -656,9 +656,8 @@ fn resolve_glob_import(&mut self, directive: &'b ImportDirective<'b>) {
|
||||
|
||||
if let Some(Def::Trait(_)) = module.def {
|
||||
self.session.span_err(directive.span, "items in traits are not importable.");
|
||||
}
|
||||
|
||||
if module.def_id() == directive.parent.def_id() {
|
||||
return;
|
||||
} else if module.def_id() == directive.parent.def_id() {
|
||||
return;
|
||||
} else if let GlobImport { is_prelude: true } = directive.subclass {
|
||||
self.prelude = Some(module);
|
||||
@@ -674,7 +673,7 @@ fn resolve_glob_import(&mut self, directive: &'b ImportDirective<'b>) {
|
||||
resolution.borrow().binding().map(|binding| (*name, binding))
|
||||
}).collect::<Vec<_>>();
|
||||
for ((name, ns), binding) in bindings {
|
||||
if binding.is_importable() && binding.is_pseudo_public() {
|
||||
if binding.pseudo_vis() == ty::Visibility::Public {
|
||||
let imported_binding = self.import(binding, directive);
|
||||
let _ = self.try_define(directive.parent, name, ns, imported_binding);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user