@@ -57,7 +57,7 @@ struct MarkSymbolVisitor<'tcx> {
5757 tcx : TyCtxt < ' tcx > ,
5858 maybe_typeck_results : Option < & ' tcx ty:: TypeckResults < ' tcx > > ,
5959 live_symbols : LocalDefIdSet ,
60- repr_has_repr_c : bool ,
60+ repr_unconditionally_treats_fields_as_live : bool ,
6161 repr_has_repr_simd : bool ,
6262 in_pat : bool ,
6363 ignore_variant_stack : Vec < DefId > ,
@@ -365,15 +365,17 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
365365 return ;
366366 }
367367
368- let had_repr_c = self . repr_has_repr_c ;
368+ let unconditionally_treated_fields_as_live =
369+ self . repr_unconditionally_treats_fields_as_live ;
369370 let had_repr_simd = self . repr_has_repr_simd ;
370- self . repr_has_repr_c = false ;
371+ self . repr_unconditionally_treats_fields_as_live = false ;
371372 self . repr_has_repr_simd = false ;
372373 match node {
373374 Node :: Item ( item) => match item. kind {
374375 hir:: ItemKind :: Struct ( ..) | hir:: ItemKind :: Union ( ..) => {
375376 let def = self . tcx . adt_def ( item. owner_id ) ;
376- self . repr_has_repr_c = def. repr ( ) . c ( ) ;
377+ self . repr_unconditionally_treats_fields_as_live =
378+ def. repr ( ) . c ( ) || def. repr ( ) . transparent ( ) ;
377379 self . repr_has_repr_simd = def. repr ( ) . simd ( ) ;
378380
379381 intravisit:: walk_item ( self , item)
@@ -411,7 +413,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
411413 _ => { }
412414 }
413415 self . repr_has_repr_simd = had_repr_simd;
414- self . repr_has_repr_c = had_repr_c ;
416+ self . repr_unconditionally_treats_fields_as_live = unconditionally_treated_fields_as_live ;
415417 }
416418
417419 fn mark_as_used_if_union ( & mut self , adt : ty:: AdtDef < ' tcx > , fields : & [ hir:: ExprField < ' _ > ] ) {
@@ -435,11 +437,11 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {
435437
436438 fn visit_variant_data ( & mut self , def : & ' tcx hir:: VariantData < ' tcx > ) {
437439 let tcx = self . tcx ;
438- let has_repr_c = self . repr_has_repr_c ;
440+ let unconditionally_treat_fields_as_live = self . repr_unconditionally_treats_fields_as_live ;
439441 let has_repr_simd = self . repr_has_repr_simd ;
440442 let live_fields = def. fields ( ) . iter ( ) . filter_map ( |f| {
441443 let def_id = f. def_id ;
442- if has_repr_c || ( f. is_positional ( ) && has_repr_simd) {
444+ if unconditionally_treat_fields_as_live || ( f. is_positional ( ) && has_repr_simd) {
443445 return Some ( def_id) ;
444446 }
445447 if !tcx. visibility ( f. hir_id . owner . def_id ) . is_public ( ) {
@@ -741,7 +743,7 @@ fn live_symbols_and_ignored_derived_traits(
741743 tcx,
742744 maybe_typeck_results : None ,
743745 live_symbols : Default :: default ( ) ,
744- repr_has_repr_c : false ,
746+ repr_unconditionally_treats_fields_as_live : false ,
745747 repr_has_repr_simd : false ,
746748 in_pat : false ,
747749 ignore_variant_stack : vec ! [ ] ,
0 commit comments