@@ -392,6 +392,19 @@ fn mono_item_linkage_and_visibility<'tcx>(
392
392
393
393
type CguNameCache = FxHashMap < ( DefId , bool ) , Symbol > ;
394
394
395
+ fn static_visibility < ' tcx > (
396
+ tcx : TyCtxt < ' tcx > ,
397
+ can_be_internalized : & mut bool ,
398
+ def_id : DefId ,
399
+ ) -> Visibility {
400
+ if tcx. is_reachable_non_generic ( def_id) {
401
+ * can_be_internalized = false ;
402
+ default_visibility ( tcx, def_id, false )
403
+ } else {
404
+ Visibility :: Hidden
405
+ }
406
+ }
407
+
395
408
fn mono_item_visibility < ' tcx > (
396
409
tcx : TyCtxt < ' tcx > ,
397
410
mono_item : & MonoItem < ' tcx > ,
@@ -403,35 +416,19 @@ fn mono_item_visibility<'tcx>(
403
416
MonoItem :: Fn ( instance) => instance,
404
417
405
418
// Misc handling for generics and such, but otherwise:
406
- MonoItem :: Static ( def_id) => {
407
- return if tcx. is_reachable_non_generic ( * def_id) {
408
- * can_be_internalized = false ;
409
- default_visibility ( tcx, * def_id, false )
410
- } else {
411
- Visibility :: Hidden
412
- } ;
413
- }
419
+ MonoItem :: Static ( def_id) => return static_visibility ( tcx, can_be_internalized, * def_id) ,
414
420
MonoItem :: GlobalAsm ( item_id) => {
415
- return if tcx. is_reachable_non_generic ( item_id. owner_id ) {
416
- * can_be_internalized = false ;
417
- default_visibility ( tcx, item_id. owner_id . to_def_id ( ) , false )
418
- } else {
419
- Visibility :: Hidden
420
- } ;
421
+ return static_visibility ( tcx, can_be_internalized, item_id. owner_id . to_def_id ( ) ) ;
421
422
}
422
423
} ;
423
424
424
425
let def_id = match instance. def {
425
426
InstanceDef :: Item ( def) => def. did ,
426
427
InstanceDef :: DropGlue ( def_id, Some ( _) ) => def_id,
427
428
429
+ // We match the visiblity of statics here
428
430
InstanceDef :: ThreadLocalShim ( def_id) => {
429
- return if tcx. is_reachable_non_generic ( def_id) {
430
- * can_be_internalized = false ;
431
- default_visibility ( tcx, def_id, false )
432
- } else {
433
- Visibility :: Hidden
434
- } ;
431
+ return static_visibility ( tcx, can_be_internalized, def_id) ;
435
432
}
436
433
437
434
// These are all compiler glue and such, never exported, always hidden.
0 commit comments