@@ -51,7 +51,8 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> {
5151 tcx : & ' a ty:: ctxt < ' tcx > ,
5252 live_symbols : Box < HashSet < ast:: NodeId > > ,
5353 struct_has_extern_repr : bool ,
54- ignore_non_const_paths : bool
54+ ignore_non_const_paths : bool ,
55+ inherited_pub_visibility : bool ,
5556}
5657
5758impl < ' a , ' tcx > MarkSymbolVisitor < ' a , ' tcx > {
@@ -62,7 +63,8 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
6263 tcx : tcx,
6364 live_symbols : box HashSet :: new ( ) ,
6465 struct_has_extern_repr : false ,
65- ignore_non_const_paths : false
66+ ignore_non_const_paths : false ,
67+ inherited_pub_visibility : false ,
6668 }
6769 }
6870
@@ -206,6 +208,8 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
206208 fn visit_node ( & mut self , node : & ast_map:: Node ) {
207209 let had_extern_repr = self . struct_has_extern_repr ;
208210 self . struct_has_extern_repr = false ;
211+ let had_inherited_pub_visibility = self . inherited_pub_visibility ;
212+ self . inherited_pub_visibility = false ;
209213 match * node {
210214 ast_map:: NodeItem ( item) => {
211215 match item. node {
@@ -217,8 +221,11 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
217221
218222 visit:: walk_item ( self , & * item) ;
219223 }
224+ ast:: ItemEnum ( ..) => {
225+ self . inherited_pub_visibility = item. vis == ast:: Public ;
226+ visit:: walk_item ( self , & * item) ;
227+ }
220228 ast:: ItemFn ( ..)
221- | ast:: ItemEnum ( ..)
222229 | ast:: ItemTy ( ..)
223230 | ast:: ItemStatic ( ..)
224231 | ast:: ItemConst ( ..) => {
@@ -244,6 +251,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
244251 _ => ( )
245252 }
246253 self . struct_has_extern_repr = had_extern_repr;
254+ self . inherited_pub_visibility = had_inherited_pub_visibility;
247255 }
248256}
249257
@@ -252,8 +260,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
252260 fn visit_struct_def ( & mut self , def : & ast:: StructDef , _: ast:: Ident ,
253261 _: & ast:: Generics , _: ast:: NodeId ) {
254262 let has_extern_repr = self . struct_has_extern_repr ;
263+ let inherited_pub_visibility = self . inherited_pub_visibility ;
255264 let live_fields = def. fields . iter ( ) . filter ( |f| {
256- has_extern_repr || match f. node . kind {
265+ has_extern_repr || inherited_pub_visibility || match f. node . kind {
257266 ast:: NamedField ( _, ast:: Public ) => true ,
258267 _ => false
259268 }
0 commit comments