]> git.lizzy.rs Git - rust.git/commitdiff
Light restructuring.
authorKyle Simpson <kyleandrew.simpson@gmail.com>
Thu, 23 Aug 2018 09:52:08 +0000 (10:52 +0100)
committerKyle Simpson <kyleandrew.simpson@gmail.com>
Thu, 23 Aug 2018 12:12:53 +0000 (13:12 +0100)
src/Cargo.lock
src/librustc_privacy/Cargo.toml
src/librustc_privacy/lib.rs

index 4b76080e500ab84af399e1e81875d01969c0b352..8299dea1c4b0eec9c92b72f453dde86db4400b7f 100644 (file)
@@ -2237,7 +2237,6 @@ dependencies = [
 name = "rustc_privacy"
 version = "0.0.0"
 dependencies = [
- "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc 0.0.0",
  "rustc_data_structures 0.0.0",
  "rustc_typeck 0.0.0",
index b7af9ec809e5448a0cd4bead8b3f49fd0e6cf7a0..62eab40f3ec9a0aa2a459382b5f6238a71408243 100644 (file)
@@ -9,7 +9,6 @@ path = "lib.rs"
 crate-type = ["dylib"]
 
 [dependencies]
-log = { version = "0.4", features = ["release_max_level_info", "std"] }
 rustc = { path = "../librustc" }
 rustc_typeck = { path = "../librustc_typeck" }
 syntax = { path = "../libsyntax" }
index f6b843bbac52bc380afe350e1d588135adb0b466..6b19f4b779107bb10a729f28b69e2c2f898c5f5d 100644 (file)
@@ -18,7 +18,6 @@
 
 #![recursion_limit="256"]
 
-#[macro_use] extern crate log;
 #[macro_use] extern crate rustc;
 #[macro_use] extern crate syntax;
 extern crate rustc_typeck;
@@ -150,7 +149,6 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
     }
 
     fn visit_item(&mut self, item: &'tcx hir::Item) {
-        debug!("visit_item({:?})", item);
         let inherited_item_level = match item.node {
             // Impls inherit level from their types and traits
             hir::ItemKind::Impl(..) => {
@@ -161,21 +159,12 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
             hir::ItemKind::ForeignMod(..) => {
                 self.prev_level
             }
-            // Impl trait return types mark their parent function.
-            // It (and its children) are revisited if the change applies.
-            hir::ItemKind::Existential(ref ty_data) => {
-                if let Some(impl_trait_fn) = ty_data.impl_trait_fn {
-                    if let Some(node_id) = self.tcx.hir.as_local_node_id(impl_trait_fn) {
-                        self.update(node_id, Some(AccessLevel::ReachableFromImplTrait));
-                    }
-                }
-                if item.vis.node.is_pub() { self.prev_level } else { None }
-            }
             // Other `pub` items inherit levels from parents
             hir::ItemKind::Const(..) | hir::ItemKind::Enum(..) | hir::ItemKind::ExternCrate(..) |
             hir::ItemKind::GlobalAsm(..) | hir::ItemKind::Fn(..) | hir::ItemKind::Mod(..) |
             hir::ItemKind::Static(..) | hir::ItemKind::Struct(..) |
             hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..) |
+            hir::ItemKind::Existential(..) |
             hir::ItemKind::Ty(..) | hir::ItemKind::Union(..) | hir::ItemKind::Use(..) => {
                 if item.vis.node.is_pub() { self.prev_level } else { None }
             }
@@ -184,8 +173,6 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
         // Update level of the item itself
         let item_level = self.update(item.id, inherited_item_level);
 
-        debug!("item_level = {:?}", item_level);
-
         // Update levels of nested things
         match item.node {
             hir::ItemKind::Enum(ref def, _) => {
@@ -230,7 +217,15 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
                     }
                 }
             }
-            hir::ItemKind::Existential(..) |
+            // Impl trait return types mark their parent function.
+            // It (and its children) are revisited if the change applies.
+            hir::ItemKind::Existential(ref ty_data) => {
+                if let Some(impl_trait_fn) = ty_data.impl_trait_fn {
+                    if let Some(node_id) = self.tcx.hir.as_local_node_id(impl_trait_fn) {
+                        self.update(node_id, Some(AccessLevel::ReachableFromImplTrait));
+                    }
+                }
+            }
             hir::ItemKind::Use(..) |
             hir::ItemKind::Static(..) |
             hir::ItemKind::Const(..) |
@@ -242,8 +237,9 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
             hir::ItemKind::ExternCrate(..) => {}
         }
 
-        let orig_level = self.prev_level;
-        self.prev_level = item_level;
+        // Store this node's access level here to propagate the correct
+        // reachability level through interfaces and children.
+        let orig_level = replace(&mut self.prev_level, item_level);
 
         // Mark all items in interfaces of reachable items as reachable
         match item.node {
@@ -1752,8 +1748,6 @@ fn privacy_access_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     }
     visitor.update(ast::CRATE_NODE_ID, Some(AccessLevel::Public));
 
-    debug!("access levels after embargo: {:?}", &visitor.access_levels);
-
     {
         let mut visitor = ObsoleteVisiblePrivateTypesVisitor {
             tcx,
@@ -1783,8 +1777,6 @@ fn privacy_access_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         krate.visit_all_item_likes(&mut DeepVisitor::new(&mut visitor));
     }
 
-    debug!("final access levels: {:?}", &visitor.access_levels);
-
     Lrc::new(visitor.access_levels)
 }