@@ -392,6 +392,19 @@ fn mono_item_linkage_and_visibility<'tcx>(
392392
393393type CguNameCache = FxHashMap < ( DefId , bool ) , Symbol > ;
394394
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+
395408fn mono_item_visibility < ' tcx > (
396409 tcx : TyCtxt < ' tcx > ,
397410 mono_item : & MonoItem < ' tcx > ,
@@ -403,35 +416,19 @@ fn mono_item_visibility<'tcx>(
403416 MonoItem :: Fn ( instance) => instance,
404417
405418 // 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) ,
414420 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 ( ) ) ;
421422 }
422423 } ;
423424
424425 let def_id = match instance. def {
425426 InstanceDef :: Item ( def) => def. did ,
426427 InstanceDef :: DropGlue ( def_id, Some ( _) ) => def_id,
427428
429+ // We match the visiblity of statics here
428430 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) ;
435432 }
436433
437434 // These are all compiler glue and such, never exported, always hidden.
0 commit comments