Skip to content

Commit 61cbc84

Browse files
committed
Make fields and macro defs exported
1 parent 243a524 commit 61cbc84

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

src/librustc/middle/reachable.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
223223
continue
224224
}
225225

226-
match self.tcx.map.find(search_item) {
227-
Some(ref item) => self.propagate_node(item, search_item),
228-
None if search_item == ast::CRATE_NODE_ID => {}
229-
None => {
230-
self.tcx.sess.bug(&format!("found unmapped ID in worklist: \
231-
{}",
232-
search_item))
233-
}
226+
if let Some(ref item) = self.tcx.map.find(search_item) {
227+
self.propagate_node(item, search_item);
234228
}
235229
}
236230
}

src/librustc_privacy/lib.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ struct EmbargoVisitor<'a, 'tcx: 'a> {
175175
// Items that are directly public without help of reexports or type aliases.
176176
// These two fields are closely related to one another in that they are only
177177
// used for generation of the `public_items` set, not for privacy checking at
178-
// all. Public items are mostly a subset of exported items with exception of
179-
// fields and exported macros - they are public, but not exported.
180-
// FIXME: Make fields and exported macros exported as well (requires fixing resulting ICEs)
178+
// all. Invariant: at any moment public items are a subset of exported items.
181179
public_items: PublicItems,
182180
prev_public: bool,
183181
}
@@ -251,11 +249,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
251249
self.maybe_insert_id(variant.node.data.id());
252250
for field in variant.node.data.fields() {
253251
// Variant fields are always public
254-
if self.prev_public {
255-
self.public_items.insert(field.node.id);
256-
}
257-
// FIXME: Make fields exported (requires fixing resulting ICEs)
258-
// if self.prev_exported { self.exported_items.insert(field.node.id); }
252+
self.maybe_insert_id(field.node.id);
259253
}
260254
}
261255
}
@@ -328,11 +322,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
328322
for field in def.fields() {
329323
// Struct fields can be public or private, so lets check
330324
if field.node.kind.visibility() == hir::Public {
331-
if self.prev_public {
332-
self.public_items.insert(field.node.id);
333-
}
334-
// FIXME: Make fields exported (requires fixing resulting ICEs)
335-
// if self.prev_exported { self.exported_items.insert(field.node.id); }
325+
self.maybe_insert_id(field.node.id);
336326
}
337327
}
338328
}
@@ -403,9 +393,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
403393
}
404394

405395
fn visit_macro_def(&mut self, md: &'v hir::MacroDef) {
406-
self.public_items.insert(md.id);
407-
// FIXME: Make exported macros exported (requires fixing resulting ICEs)
408-
// self.exported_items.insert(md.id);
396+
self.maybe_insert_id(md.id);
409397
}
410398
}
411399

0 commit comments

Comments
 (0)