@@ -51,7 +51,8 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> {
51
51
tcx : & ' a ty:: ctxt < ' tcx > ,
52
52
live_symbols : Box < HashSet < ast:: NodeId > > ,
53
53
struct_has_extern_repr : bool ,
54
- ignore_non_const_paths : bool
54
+ ignore_non_const_paths : bool ,
55
+ inherited_pub_visibility : bool ,
55
56
}
56
57
57
58
impl < ' a , ' tcx > MarkSymbolVisitor < ' a , ' tcx > {
@@ -62,7 +63,8 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
62
63
tcx : tcx,
63
64
live_symbols : box HashSet :: new ( ) ,
64
65
struct_has_extern_repr : false ,
65
- ignore_non_const_paths : false
66
+ ignore_non_const_paths : false ,
67
+ inherited_pub_visibility : false ,
66
68
}
67
69
}
68
70
@@ -206,6 +208,8 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
206
208
fn visit_node ( & mut self , node : & ast_map:: Node ) {
207
209
let had_extern_repr = self . struct_has_extern_repr ;
208
210
self . struct_has_extern_repr = false ;
211
+ let had_inherited_pub_visibility = self . inherited_pub_visibility ;
212
+ self . inherited_pub_visibility = false ;
209
213
match * node {
210
214
ast_map:: NodeItem ( item) => {
211
215
match item. node {
@@ -217,8 +221,11 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
217
221
218
222
visit:: walk_item ( self , & * item) ;
219
223
}
224
+ ast:: ItemEnum ( ..) => {
225
+ self . inherited_pub_visibility = item. vis == ast:: Public ;
226
+ visit:: walk_item ( self , & * item) ;
227
+ }
220
228
ast:: ItemFn ( ..)
221
- | ast:: ItemEnum ( ..)
222
229
| ast:: ItemTy ( ..)
223
230
| ast:: ItemStatic ( ..)
224
231
| ast:: ItemConst ( ..) => {
@@ -244,6 +251,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
244
251
_ => ( )
245
252
}
246
253
self . struct_has_extern_repr = had_extern_repr;
254
+ self . inherited_pub_visibility = had_inherited_pub_visibility;
247
255
}
248
256
}
249
257
@@ -252,8 +260,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
252
260
fn visit_struct_def ( & mut self , def : & ast:: StructDef , _: ast:: Ident ,
253
261
_: & ast:: Generics , _: ast:: NodeId ) {
254
262
let has_extern_repr = self . struct_has_extern_repr ;
263
+ let inherited_pub_visibility = self . inherited_pub_visibility ;
255
264
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 {
257
266
ast:: NamedField ( _, ast:: Public ) => true ,
258
267
_ => false
259
268
}
0 commit comments