@@ -9,7 +9,7 @@ use rustc_hir::Node;
99use rustc_index:: vec:: IndexVec ;
1010use rustc_middle:: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
1111use rustc_middle:: middle:: exported_symbols:: {
12- metadata_symbol_name, ExportedSymbol , SymbolExportLevel ,
12+ metadata_symbol_name, ExportedSymbol , SymbolExportInfo , SymbolExportLevel ,
1313} ;
1414use rustc_middle:: ty:: query:: { ExternProviders , Providers } ;
1515use rustc_middle:: ty:: subst:: { GenericArgKind , SubstsRef } ;
@@ -42,7 +42,7 @@ pub fn crates_export_threshold(crate_types: &[CrateType]) -> SymbolExportLevel {
4242 }
4343}
4444
45- fn reachable_non_generics_provider ( tcx : TyCtxt < ' _ > , cnum : CrateNum ) -> DefIdMap < SymbolExportLevel > {
45+ fn reachable_non_generics_provider ( tcx : TyCtxt < ' _ > , cnum : CrateNum ) -> DefIdMap < SymbolExportInfo > {
4646 assert_eq ! ( cnum, LOCAL_CRATE ) ;
4747
4848 if !tcx. sess . opts . output_types . should_codegen ( ) {
@@ -129,12 +129,17 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<
129129 tcx. symbol_name( Instance :: mono( tcx, def_id. to_def_id( ) ) ) ,
130130 export_level
131131 ) ;
132- ( def_id. to_def_id ( ) , export_level)
132+ ( def_id. to_def_id ( ) , SymbolExportInfo {
133+ level : export_level,
134+ } )
133135 } )
134136 . collect ( ) ;
135137
136138 if let Some ( id) = tcx. proc_macro_decls_static ( ( ) ) {
137- reachable_non_generics. insert ( id. to_def_id ( ) , SymbolExportLevel :: C ) ;
139+ reachable_non_generics. insert (
140+ id. to_def_id ( ) ,
141+ SymbolExportInfo { level : SymbolExportLevel :: C } ,
142+ ) ;
138143 }
139144
140145 reachable_non_generics
@@ -143,8 +148,8 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<
143148fn is_reachable_non_generic_provider_local ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> bool {
144149 let export_threshold = threshold ( tcx) ;
145150
146- if let Some ( & level ) = tcx. reachable_non_generics ( def_id. krate ) . get ( & def_id) {
147- level. is_below_threshold ( export_threshold)
151+ if let Some ( & info ) = tcx. reachable_non_generics ( def_id. krate ) . get ( & def_id) {
152+ info . level . is_below_threshold ( export_threshold)
148153 } else {
149154 false
150155 }
@@ -157,7 +162,7 @@ fn is_reachable_non_generic_provider_extern(tcx: TyCtxt<'_>, def_id: DefId) -> b
157162fn exported_symbols_provider_local < ' tcx > (
158163 tcx : TyCtxt < ' tcx > ,
159164 cnum : CrateNum ,
160- ) -> & ' tcx [ ( ExportedSymbol < ' tcx > , SymbolExportLevel ) ] {
165+ ) -> & ' tcx [ ( ExportedSymbol < ' tcx > , SymbolExportInfo ) ] {
161166 assert_eq ! ( cnum, LOCAL_CRATE ) ;
162167
163168 if !tcx. sess . opts . output_types . should_codegen ( ) {
@@ -167,21 +172,27 @@ fn exported_symbols_provider_local<'tcx>(
167172 let mut symbols: Vec < _ > = tcx
168173 . reachable_non_generics ( LOCAL_CRATE )
169174 . iter ( )
170- . map ( |( & def_id, & level ) | ( ExportedSymbol :: NonGeneric ( def_id) , level ) )
175+ . map ( |( & def_id, & info ) | ( ExportedSymbol :: NonGeneric ( def_id) , info ) )
171176 . collect ( ) ;
172177
173178 if tcx. entry_fn ( ( ) ) . is_some ( ) {
174179 let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( tcx, "main" ) ) ;
175180
176- symbols. push ( ( exported_symbol, SymbolExportLevel :: C ) ) ;
181+ symbols. push ( (
182+ exported_symbol,
183+ SymbolExportInfo { level : SymbolExportLevel :: C } ,
184+ ) ) ;
177185 }
178186
179187 if tcx. allocator_kind ( ( ) ) . is_some ( ) {
180188 for method in ALLOCATOR_METHODS {
181189 let symbol_name = format ! ( "__rust_{}" , method. name) ;
182190 let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( tcx, & symbol_name) ) ;
183191
184- symbols. push ( ( exported_symbol, SymbolExportLevel :: Rust ) ) ;
192+ symbols. push ( (
193+ exported_symbol,
194+ SymbolExportInfo { level : SymbolExportLevel :: Rust } ,
195+ ) ) ;
185196 }
186197 }
187198
@@ -194,7 +205,10 @@ fn exported_symbols_provider_local<'tcx>(
194205
195206 symbols. extend ( PROFILER_WEAK_SYMBOLS . iter ( ) . map ( |sym| {
196207 let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( tcx, sym) ) ;
197- ( exported_symbol, SymbolExportLevel :: C )
208+ (
209+ exported_symbol,
210+ SymbolExportInfo { level : SymbolExportLevel :: C } ,
211+ )
198212 } ) ) ;
199213 }
200214
@@ -204,15 +218,21 @@ fn exported_symbols_provider_local<'tcx>(
204218
205219 symbols. extend ( MSAN_WEAK_SYMBOLS . iter ( ) . map ( |sym| {
206220 let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( tcx, sym) ) ;
207- ( exported_symbol, SymbolExportLevel :: C )
221+ (
222+ exported_symbol,
223+ SymbolExportInfo { level : SymbolExportLevel :: C } ,
224+ )
208225 } ) ) ;
209226 }
210227
211228 if tcx. sess . crate_types ( ) . contains ( & CrateType :: Dylib ) {
212229 let symbol_name = metadata_symbol_name ( tcx) ;
213230 let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( tcx, & symbol_name) ) ;
214231
215- symbols. push ( ( exported_symbol, SymbolExportLevel :: Rust ) ) ;
232+ symbols. push ( (
233+ exported_symbol,
234+ SymbolExportInfo { level : SymbolExportLevel :: Rust } ,
235+ ) ) ;
216236 }
217237
218238 if tcx. sess . opts . share_generics ( ) && tcx. local_crate_exports_generics ( ) {
@@ -245,7 +265,12 @@ fn exported_symbols_provider_local<'tcx>(
245265 MonoItem :: Fn ( Instance { def : InstanceDef :: Item ( def) , substs } ) => {
246266 if substs. non_erasable_generics ( ) . next ( ) . is_some ( ) {
247267 let symbol = ExportedSymbol :: Generic ( def. did , substs) ;
248- symbols. push ( ( symbol, SymbolExportLevel :: Rust ) ) ;
268+ symbols. push ( (
269+ symbol,
270+ SymbolExportInfo {
271+ level : SymbolExportLevel :: Rust ,
272+ } ,
273+ ) ) ;
249274 }
250275 }
251276 MonoItem :: Fn ( Instance { def : InstanceDef :: DropGlue ( _, Some ( ty) ) , substs } ) => {
@@ -254,7 +279,12 @@ fn exported_symbols_provider_local<'tcx>(
254279 substs. non_erasable_generics( ) . next( ) ,
255280 Some ( GenericArgKind :: Type ( ty) )
256281 ) ;
257- symbols. push ( ( ExportedSymbol :: DropGlue ( ty) , SymbolExportLevel :: Rust ) ) ;
282+ symbols. push ( (
283+ ExportedSymbol :: DropGlue ( ty) ,
284+ SymbolExportInfo {
285+ level : SymbolExportLevel :: Rust ,
286+ } ,
287+ ) ) ;
258288 }
259289 _ => {
260290 // Any other symbols don't qualify for sharing
0 commit comments