@@ -57,7 +57,7 @@ struct MarkSymbolVisitor<'tcx> {
57
57
tcx : TyCtxt < ' tcx > ,
58
58
maybe_typeck_results : Option < & ' tcx ty:: TypeckResults < ' tcx > > ,
59
59
live_symbols : LocalDefIdSet ,
60
- repr_has_repr_c : bool ,
60
+ repr_unconditionally_treats_fields_as_live : bool ,
61
61
repr_has_repr_simd : bool ,
62
62
in_pat : bool ,
63
63
ignore_variant_stack : Vec < DefId > ,
@@ -365,15 +365,17 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
365
365
return ;
366
366
}
367
367
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 ;
369
370
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 ;
371
372
self . repr_has_repr_simd = false ;
372
373
match node {
373
374
Node :: Item ( item) => match item. kind {
374
375
hir:: ItemKind :: Struct ( ..) | hir:: ItemKind :: Union ( ..) => {
375
376
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 ( ) ;
377
379
self . repr_has_repr_simd = def. repr ( ) . simd ( ) ;
378
380
379
381
intravisit:: walk_item ( self , item)
@@ -411,7 +413,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
411
413
_ => { }
412
414
}
413
415
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 ;
415
417
}
416
418
417
419
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> {
435
437
436
438
fn visit_variant_data ( & mut self , def : & ' tcx hir:: VariantData < ' tcx > ) {
437
439
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 ;
439
441
let has_repr_simd = self . repr_has_repr_simd ;
440
442
let live_fields = def. fields ( ) . iter ( ) . filter_map ( |f| {
441
443
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) {
443
445
return Some ( def_id) ;
444
446
}
445
447
if !tcx. visibility ( f. hir_id . owner . def_id ) . is_public ( ) {
@@ -741,7 +743,7 @@ fn live_symbols_and_ignored_derived_traits(
741
743
tcx,
742
744
maybe_typeck_results : None ,
743
745
live_symbols : Default :: default ( ) ,
744
- repr_has_repr_c : false ,
746
+ repr_unconditionally_treats_fields_as_live : false ,
745
747
repr_has_repr_simd : false ,
746
748
in_pat : false ,
747
749
ignore_variant_stack : vec ! [ ] ,
0 commit comments