Skip to content

Commit e2bb53c

Browse files
committed
Auto merge of #29291 - petrochenkov:privacy, r=alexcrichton
The public set is expanded with trait items, impls and their items, foreign items, exported macros, variant fields, i.e. all the missing parts. Now it's a subset of the exported set. This is needed for #29083 because stability annotation pass uses the public set and all things listed above need to be annotated. Rustdoc can now be migrated to the public set as well, I guess. Exported set is now slightly more correct with regard to exported items in blocks - 1) blocks in foreign items are considered and 2) publicity is not inherited from the block's parent - if a function is public it doesn't mean structures defined in its body are public. r? @alexcrichton or maybe someone else
2 parents a1fd944 + ab7b345 commit e2bb53c

File tree

7 files changed

+217
-143
lines changed

7 files changed

+217
-143
lines changed

src/librustc/middle/reachable.rs

+6-17
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,11 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ReachableContext<'a, 'tcx> {
125125
hir::ExprMethodCall(..) => {
126126
let method_call = ty::MethodCall::expr(expr.id);
127127
let def_id = self.tcx.tables.borrow().method_map[&method_call].def_id;
128-
match self.tcx.impl_or_trait_item(def_id).container() {
129-
ty::ImplContainer(_) => {
130-
if let Some(node_id) = self.tcx.map.as_local_node_id(def_id) {
131-
if self.def_id_represents_local_inlined_item(def_id) {
132-
self.worklist.push(node_id)
133-
}
134-
self.reachable_symbols.insert(node_id);
135-
}
128+
if let Some(node_id) = self.tcx.map.as_local_node_id(def_id) {
129+
if self.def_id_represents_local_inlined_item(def_id) {
130+
self.worklist.push(node_id)
136131
}
137-
ty::TraitContainer(_) => {}
132+
self.reachable_symbols.insert(node_id);
138133
}
139134
}
140135
_ => {}
@@ -228,14 +223,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
228223
continue
229224
}
230225

231-
match self.tcx.map.find(search_item) {
232-
Some(ref item) => self.propagate_node(item, search_item),
233-
None if search_item == ast::CRATE_NODE_ID => {}
234-
None => {
235-
self.tcx.sess.bug(&format!("found unmapped ID in worklist: \
236-
{}",
237-
search_item))
238-
}
226+
if let Some(ref item) = self.tcx.map.find(search_item) {
227+
self.propagate_node(item, search_item);
239228
}
240229
}
241230
}

src/librustc/middle/stability.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Annotator<'a, 'tcx> {
217217

218218
fn visit_impl_item(&mut self, ii: &hir::ImplItem) {
219219
self.annotate(ii.id, true, &ii.attrs, ii.span,
220-
|v| visit::walk_impl_item(v, ii), true);
220+
|v| visit::walk_impl_item(v, ii), false);
221221
}
222222

223223
fn visit_variant(&mut self, var: &Variant, g: &'v Generics, item_id: NodeId) {
@@ -227,7 +227,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Annotator<'a, 'tcx> {
227227

228228
fn visit_struct_field(&mut self, s: &StructField) {
229229
self.annotate(s.node.id, true, &s.node.attrs, s.span,
230-
|v| visit::walk_struct_field(v, s), true);
230+
|v| visit::walk_struct_field(v, s), !s.node.kind.is_unnamed());
231231
}
232232

233233
fn visit_foreign_item(&mut self, i: &hir::ForeignItem) {

src/librustc_front/hir.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,12 @@ impl StructFieldKind {
11481148
NamedField(..) => false,
11491149
}
11501150
}
1151+
1152+
pub fn visibility(&self) -> Visibility {
1153+
match *self {
1154+
NamedField(_, vis) | UnnamedField(vis) => vis
1155+
}
1156+
}
11511157
}
11521158

11531159
/// Fields and Ids of enum variants and structs

0 commit comments

Comments
 (0)