Skip to content

Commit 85a05d1

Browse files
committed
Light restructuring.
1 parent 3536359 commit 85a05d1

File tree

3 files changed

+13
-23
lines changed

3 files changed

+13
-23
lines changed

src/Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,6 @@ dependencies = [
22372237
name = "rustc_privacy"
22382238
version = "0.0.0"
22392239
dependencies = [
2240-
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
22412240
"rustc 0.0.0",
22422241
"rustc_data_structures 0.0.0",
22432242
"rustc_typeck 0.0.0",

src/librustc_privacy/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ path = "lib.rs"
99
crate-type = ["dylib"]
1010

1111
[dependencies]
12-
log = { version = "0.4", features = ["release_max_level_info", "std"] }
1312
rustc = { path = "../librustc" }
1413
rustc_typeck = { path = "../librustc_typeck" }
1514
syntax = { path = "../libsyntax" }

src/librustc_privacy/lib.rs

+13-21
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#![recursion_limit="256"]
2020

21-
#[macro_use] extern crate log;
2221
#[macro_use] extern crate rustc;
2322
#[macro_use] extern crate syntax;
2423
extern crate rustc_typeck;
@@ -150,7 +149,6 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
150149
}
151150

152151
fn visit_item(&mut self, item: &'tcx hir::Item) {
153-
debug!("visit_item({:?})", item);
154152
let inherited_item_level = match item.node {
155153
// Impls inherit level from their types and traits
156154
hir::ItemKind::Impl(..) => {
@@ -161,21 +159,12 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
161159
hir::ItemKind::ForeignMod(..) => {
162160
self.prev_level
163161
}
164-
// Impl trait return types mark their parent function.
165-
// It (and its children) are revisited if the change applies.
166-
hir::ItemKind::Existential(ref ty_data) => {
167-
if let Some(impl_trait_fn) = ty_data.impl_trait_fn {
168-
if let Some(node_id) = self.tcx.hir.as_local_node_id(impl_trait_fn) {
169-
self.update(node_id, Some(AccessLevel::ReachableFromImplTrait));
170-
}
171-
}
172-
if item.vis.node.is_pub() { self.prev_level } else { None }
173-
}
174162
// Other `pub` items inherit levels from parents
175163
hir::ItemKind::Const(..) | hir::ItemKind::Enum(..) | hir::ItemKind::ExternCrate(..) |
176164
hir::ItemKind::GlobalAsm(..) | hir::ItemKind::Fn(..) | hir::ItemKind::Mod(..) |
177165
hir::ItemKind::Static(..) | hir::ItemKind::Struct(..) |
178166
hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..) |
167+
hir::ItemKind::Existential(..) |
179168
hir::ItemKind::Ty(..) | hir::ItemKind::Union(..) | hir::ItemKind::Use(..) => {
180169
if item.vis.node.is_pub() { self.prev_level } else { None }
181170
}
@@ -184,8 +173,6 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
184173
// Update level of the item itself
185174
let item_level = self.update(item.id, inherited_item_level);
186175

187-
debug!("item_level = {:?}", item_level);
188-
189176
// Update levels of nested things
190177
match item.node {
191178
hir::ItemKind::Enum(ref def, _) => {
@@ -230,7 +217,15 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
230217
}
231218
}
232219
}
233-
hir::ItemKind::Existential(..) |
220+
// Impl trait return types mark their parent function.
221+
// It (and its children) are revisited if the change applies.
222+
hir::ItemKind::Existential(ref ty_data) => {
223+
if let Some(impl_trait_fn) = ty_data.impl_trait_fn {
224+
if let Some(node_id) = self.tcx.hir.as_local_node_id(impl_trait_fn) {
225+
self.update(node_id, Some(AccessLevel::ReachableFromImplTrait));
226+
}
227+
}
228+
}
234229
hir::ItemKind::Use(..) |
235230
hir::ItemKind::Static(..) |
236231
hir::ItemKind::Const(..) |
@@ -242,8 +237,9 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
242237
hir::ItemKind::ExternCrate(..) => {}
243238
}
244239

245-
let orig_level = self.prev_level;
246-
self.prev_level = item_level;
240+
// Store this node's access level here to propagate the correct
241+
// reachability level through interfaces and children.
242+
let orig_level = replace(&mut self.prev_level, item_level);
247243

248244
// Mark all items in interfaces of reachable items as reachable
249245
match item.node {
@@ -1752,8 +1748,6 @@ fn privacy_access_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
17521748
}
17531749
visitor.update(ast::CRATE_NODE_ID, Some(AccessLevel::Public));
17541750

1755-
debug!("access levels after embargo: {:?}", &visitor.access_levels);
1756-
17571751
{
17581752
let mut visitor = ObsoleteVisiblePrivateTypesVisitor {
17591753
tcx,
@@ -1783,8 +1777,6 @@ fn privacy_access_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
17831777
krate.visit_all_item_likes(&mut DeepVisitor::new(&mut visitor));
17841778
}
17851779

1786-
debug!("final access levels: {:?}", &visitor.access_levels);
1787-
17881780
Lrc::new(visitor.access_levels)
17891781
}
17901782

0 commit comments

Comments
 (0)