about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-08-19 21:46:28 +0000
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-09-01 22:29:26 +0000
commit5dc1196191c2f1edba8baaf841fdc07f9f8eea0b (patch)
tree712b819e856c6daece684b89689d9c4d2ffd9d07
parent48a435a90fb227f0da20b610438618dfc2c49a4e (diff)
downloadrust-5dc1196191c2f1edba8baaf841fdc07f9f8eea0b.tar.gz
rust-5dc1196191c2f1edba8baaf841fdc07f9f8eea0b.zip
Refactor away `binding.is_pseudo_public()`.
-rw-r--r--src/librustc_resolve/lib.rs4
-rw-r--r--src/librustc_resolve/resolve_imports.rs11
2 files changed, 5 insertions, 10 deletions
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 54efc4ae30a..e27936b9129 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -885,10 +885,6 @@ impl<'a> NameBinding<'a> {
         }
     }
 
-    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 }
diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs
index 8c6d89c29bd..eedbccbb039 100644
--- a/src/librustc_resolve/resolve_imports.rs
+++ b/src/librustc_resolve/resolve_imports.rs
@@ -168,7 +168,7 @@ impl<'a> Resolver<'a> {
         };
 
         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 @@ impl<'a> Resolver<'a> {
         };
 
         // 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 @@ impl<'a, 'b:'a> ImportResolver<'a, '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 @@ impl<'a, 'b:'a> ImportResolver<'a, '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);
             }