@@ -109,8 +109,8 @@ use rustc_middle::bug;
109
109
use rustc_middle:: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
110
110
use rustc_middle:: middle:: exported_symbols:: { SymbolExportInfo , SymbolExportLevel } ;
111
111
use rustc_middle:: mir:: mono:: {
112
- CodegenUnit , CodegenUnitNameBuilder , InstantiationMode , Linkage , LinkageInfo , MonoItem ,
113
- MonoItemData , Visibility ,
112
+ CodegenUnit , CodegenUnitNameBuilder , InstantiationMode , Linkage , MonoItem , MonoItemData ,
113
+ Visibility ,
114
114
} ;
115
115
use rustc_middle:: ty:: print:: { characteristic_def_id_of_type, with_no_trimmed_paths} ;
116
116
use rustc_middle:: ty:: visit:: TypeVisitableExt ;
@@ -245,7 +245,7 @@ where
245
245
let cgu = codegen_units. entry ( cgu_name) . or_insert_with ( || CodegenUnit :: new ( cgu_name) ) ;
246
246
247
247
let mut can_be_internalized = true ;
248
- let ( linkage_info , visibility) = mono_item_linkage_info_and_visibility (
248
+ let ( linkage , visibility) = mono_item_linkage_and_visibility (
249
249
cx. tcx ,
250
250
& mono_item,
251
251
& mut can_be_internalized,
@@ -259,7 +259,7 @@ where
259
259
260
260
cgu. items_mut ( ) . insert ( mono_item, MonoItemData {
261
261
inlined : false ,
262
- linkage_info ,
262
+ linkage ,
263
263
visibility,
264
264
size_estimate,
265
265
} ) ;
@@ -278,7 +278,7 @@ where
278
278
// This is a CGU-private copy.
279
279
cgu. items_mut ( ) . entry ( inlined_item) . or_insert_with ( || MonoItemData {
280
280
inlined : true ,
281
- linkage_info : LinkageInfo :: ImplicitInternal ,
281
+ linkage : Linkage :: Internal ,
282
282
visibility : Visibility :: Default ,
283
283
size_estimate : inlined_item. size_estimate ( cx. tcx ) ,
284
284
} ) ;
@@ -589,8 +589,7 @@ fn internalize_symbols<'tcx>(
589
589
590
590
// If we got here, we did not find any uses from other CGUs, so
591
591
// it's fine to make this monomorphization internal.
592
- debug_assert_eq ! ( data. linkage_info, LinkageInfo :: ImplicitExternal ) ;
593
- data. linkage_info = LinkageInfo :: ImplicitInternal ;
592
+ data. linkage = Linkage :: Internal ;
594
593
data. visibility = Visibility :: Default ;
595
594
}
596
595
}
@@ -608,7 +607,7 @@ fn mark_code_coverage_dead_code_cgu<'tcx>(codegen_units: &mut [CodegenUnit<'tcx>
608
607
// function symbols to be included via `-u` or `/include` linker args.
609
608
let dead_code_cgu = codegen_units
610
609
. iter_mut ( )
611
- . filter ( |cgu| cgu. items ( ) . iter ( ) . any ( |( _, data) | data. linkage_info . is_external ( ) ) )
610
+ . filter ( |cgu| cgu. items ( ) . iter ( ) . any ( |( _, data) | data. linkage == Linkage :: External ) )
612
611
. min_by_key ( |cgu| cgu. size_estimate ( ) ) ;
613
612
614
613
// If there are no CGUs that have externally linked items, then we just
@@ -737,26 +736,24 @@ fn fallback_cgu_name(name_builder: &mut CodegenUnitNameBuilder<'_>) -> Symbol {
737
736
name_builder. build_cgu_name ( LOCAL_CRATE , & [ "fallback" ] , Some ( "cgu" ) )
738
737
}
739
738
740
- fn mono_item_linkage_info_and_visibility < ' tcx > (
739
+ fn mono_item_linkage_and_visibility < ' tcx > (
741
740
tcx : TyCtxt < ' tcx > ,
742
741
mono_item : & MonoItem < ' tcx > ,
743
742
can_be_internalized : & mut bool ,
744
743
can_export_generics : bool ,
745
744
always_export_generics : bool ,
746
- ) -> ( LinkageInfo , Visibility ) {
745
+ ) -> ( Linkage , Visibility ) {
747
746
if let Some ( explicit_linkage) = mono_item. explicit_linkage ( tcx) {
748
- ( LinkageInfo :: Explicit ( explicit_linkage) , Visibility :: Default )
749
- } else {
750
- let vis = mono_item_visibility (
751
- tcx,
752
- mono_item,
753
- can_be_internalized,
754
- can_export_generics,
755
- always_export_generics,
756
- ) ;
757
-
758
- ( LinkageInfo :: ImplicitExternal , vis)
747
+ return ( explicit_linkage, Visibility :: Default ) ;
759
748
}
749
+ let vis = mono_item_visibility (
750
+ tcx,
751
+ mono_item,
752
+ can_be_internalized,
753
+ can_export_generics,
754
+ always_export_generics,
755
+ ) ;
756
+ ( Linkage :: External , vis)
760
757
}
761
758
762
759
type CguNameCache = UnordMap < ( DefId , bool ) , Symbol > ;
@@ -1036,15 +1033,15 @@ fn debug_dump<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx>, label: &str, cgus: &[CodegenUnit<
1036
1033
writeln ! ( s, " - items: {num_items}, mean size: {mean_size:.1}, sizes: {sizes}" , ) ;
1037
1034
1038
1035
for ( item, data) in cgu. items_in_deterministic_order ( tcx) {
1039
- let linkage_info = data. linkage_info ;
1036
+ let linkage = data. linkage ;
1040
1037
let symbol_name = item. symbol_name ( tcx) . name ;
1041
1038
let symbol_hash_start = symbol_name. rfind ( 'h' ) ;
1042
1039
let symbol_hash = symbol_hash_start. map_or ( "<no hash>" , |i| & symbol_name[ i..] ) ;
1043
1040
let kind = if !data. inlined { "root" } else { "inlined" } ;
1044
1041
let size = data. size_estimate ;
1045
1042
let _ = with_no_trimmed_paths ! ( writeln!(
1046
1043
s,
1047
- " - {item} [{linkage_info :?}] [{symbol_hash}] ({kind}, size: {size})"
1044
+ " - {item} [{linkage :?}] [{symbol_hash}] ({kind}, size: {size})"
1048
1045
) ) ;
1049
1046
}
1050
1047
@@ -1197,7 +1194,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
1197
1194
1198
1195
for cgu in codegen_units {
1199
1196
for ( & mono_item, & data) in cgu. items ( ) {
1200
- item_to_cgus. entry ( mono_item) . or_default ( ) . push ( ( cgu. name ( ) , data. linkage_info ) ) ;
1197
+ item_to_cgus. entry ( mono_item) . or_default ( ) . push ( ( cgu. name ( ) , data. linkage ) ) ;
1201
1198
}
1202
1199
}
1203
1200
@@ -1210,11 +1207,11 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
1210
1207
let cgus = item_to_cgus. get_mut ( i) . unwrap_or ( & mut empty) ;
1211
1208
cgus. sort_by_key ( |( name, _) | * name) ;
1212
1209
cgus. dedup ( ) ;
1213
- for & ( ref cgu_name, linkage_info ) in cgus. iter ( ) {
1210
+ for & ( ref cgu_name, linkage ) in cgus. iter ( ) {
1214
1211
output. push ( ' ' ) ;
1215
1212
output. push_str ( cgu_name. as_str ( ) ) ;
1216
1213
1217
- let linkage_abbrev = match linkage_info . into_linkage ( ) {
1214
+ let linkage_abbrev = match linkage {
1218
1215
Linkage :: External => "External" ,
1219
1216
Linkage :: AvailableExternally => "Available" ,
1220
1217
Linkage :: LinkOnceAny => "OnceAny" ,
0 commit comments