@@ -9,7 +9,7 @@ use rustc_hir::Node;
9
9
use rustc_index:: vec:: IndexVec ;
10
10
use rustc_middle:: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
11
11
use rustc_middle:: middle:: exported_symbols:: {
12
- metadata_symbol_name, ExportedSymbol , SymbolExportLevel ,
12
+ metadata_symbol_name, ExportedSymbol , SymbolExportInfo , SymbolExportLevel ,
13
13
} ;
14
14
use rustc_middle:: ty:: query:: { ExternProviders , Providers } ;
15
15
use rustc_middle:: ty:: subst:: { GenericArgKind , SubstsRef } ;
@@ -42,7 +42,7 @@ pub fn crates_export_threshold(crate_types: &[CrateType]) -> SymbolExportLevel {
42
42
}
43
43
}
44
44
45
- fn reachable_non_generics_provider ( tcx : TyCtxt < ' _ > , cnum : CrateNum ) -> DefIdMap < SymbolExportLevel > {
45
+ fn reachable_non_generics_provider ( tcx : TyCtxt < ' _ > , cnum : CrateNum ) -> DefIdMap < SymbolExportInfo > {
46
46
assert_eq ! ( cnum, LOCAL_CRATE ) ;
47
47
48
48
if !tcx. sess . opts . output_types . should_codegen ( ) {
@@ -129,12 +129,17 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<
129
129
tcx. symbol_name( Instance :: mono( tcx, def_id. to_def_id( ) ) ) ,
130
130
export_level
131
131
) ;
132
- ( def_id. to_def_id ( ) , export_level)
132
+ ( def_id. to_def_id ( ) , SymbolExportInfo {
133
+ level : export_level,
134
+ } )
133
135
} )
134
136
. collect ( ) ;
135
137
136
138
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
+ ) ;
138
143
}
139
144
140
145
reachable_non_generics
@@ -143,8 +148,8 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<
143
148
fn is_reachable_non_generic_provider_local ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> bool {
144
149
let export_threshold = threshold ( tcx) ;
145
150
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)
148
153
} else {
149
154
false
150
155
}
@@ -157,7 +162,7 @@ fn is_reachable_non_generic_provider_extern(tcx: TyCtxt<'_>, def_id: DefId) -> b
157
162
fn exported_symbols_provider_local < ' tcx > (
158
163
tcx : TyCtxt < ' tcx > ,
159
164
cnum : CrateNum ,
160
- ) -> & ' tcx [ ( ExportedSymbol < ' tcx > , SymbolExportLevel ) ] {
165
+ ) -> & ' tcx [ ( ExportedSymbol < ' tcx > , SymbolExportInfo ) ] {
161
166
assert_eq ! ( cnum, LOCAL_CRATE ) ;
162
167
163
168
if !tcx. sess . opts . output_types . should_codegen ( ) {
@@ -167,21 +172,27 @@ fn exported_symbols_provider_local<'tcx>(
167
172
let mut symbols: Vec < _ > = tcx
168
173
. reachable_non_generics ( LOCAL_CRATE )
169
174
. iter ( )
170
- . map ( |( & def_id, & level ) | ( ExportedSymbol :: NonGeneric ( def_id) , level ) )
175
+ . map ( |( & def_id, & info ) | ( ExportedSymbol :: NonGeneric ( def_id) , info ) )
171
176
. collect ( ) ;
172
177
173
178
if tcx. entry_fn ( ( ) ) . is_some ( ) {
174
179
let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( tcx, "main" ) ) ;
175
180
176
- symbols. push ( ( exported_symbol, SymbolExportLevel :: C ) ) ;
181
+ symbols. push ( (
182
+ exported_symbol,
183
+ SymbolExportInfo { level : SymbolExportLevel :: C } ,
184
+ ) ) ;
177
185
}
178
186
179
187
if tcx. allocator_kind ( ( ) ) . is_some ( ) {
180
188
for method in ALLOCATOR_METHODS {
181
189
let symbol_name = format ! ( "__rust_{}" , method. name) ;
182
190
let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( tcx, & symbol_name) ) ;
183
191
184
- symbols. push ( ( exported_symbol, SymbolExportLevel :: Rust ) ) ;
192
+ symbols. push ( (
193
+ exported_symbol,
194
+ SymbolExportInfo { level : SymbolExportLevel :: Rust } ,
195
+ ) ) ;
185
196
}
186
197
}
187
198
@@ -194,7 +205,10 @@ fn exported_symbols_provider_local<'tcx>(
194
205
195
206
symbols. extend ( PROFILER_WEAK_SYMBOLS . iter ( ) . map ( |sym| {
196
207
let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( tcx, sym) ) ;
197
- ( exported_symbol, SymbolExportLevel :: C )
208
+ (
209
+ exported_symbol,
210
+ SymbolExportInfo { level : SymbolExportLevel :: C } ,
211
+ )
198
212
} ) ) ;
199
213
}
200
214
@@ -204,15 +218,21 @@ fn exported_symbols_provider_local<'tcx>(
204
218
205
219
symbols. extend ( MSAN_WEAK_SYMBOLS . iter ( ) . map ( |sym| {
206
220
let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( tcx, sym) ) ;
207
- ( exported_symbol, SymbolExportLevel :: C )
221
+ (
222
+ exported_symbol,
223
+ SymbolExportInfo { level : SymbolExportLevel :: C } ,
224
+ )
208
225
} ) ) ;
209
226
}
210
227
211
228
if tcx. sess . crate_types ( ) . contains ( & CrateType :: Dylib ) {
212
229
let symbol_name = metadata_symbol_name ( tcx) ;
213
230
let exported_symbol = ExportedSymbol :: NoDefId ( SymbolName :: new ( tcx, & symbol_name) ) ;
214
231
215
- symbols. push ( ( exported_symbol, SymbolExportLevel :: Rust ) ) ;
232
+ symbols. push ( (
233
+ exported_symbol,
234
+ SymbolExportInfo { level : SymbolExportLevel :: Rust } ,
235
+ ) ) ;
216
236
}
217
237
218
238
if tcx. sess . opts . share_generics ( ) && tcx. local_crate_exports_generics ( ) {
@@ -245,7 +265,12 @@ fn exported_symbols_provider_local<'tcx>(
245
265
MonoItem :: Fn ( Instance { def : InstanceDef :: Item ( def) , substs } ) => {
246
266
if substs. non_erasable_generics ( ) . next ( ) . is_some ( ) {
247
267
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
+ ) ) ;
249
274
}
250
275
}
251
276
MonoItem :: Fn ( Instance { def : InstanceDef :: DropGlue ( _, Some ( ty) ) , substs } ) => {
@@ -254,7 +279,12 @@ fn exported_symbols_provider_local<'tcx>(
254
279
substs. non_erasable_generics( ) . next( ) ,
255
280
Some ( GenericArgKind :: Type ( ty) )
256
281
) ;
257
- symbols. push ( ( ExportedSymbol :: DropGlue ( ty) , SymbolExportLevel :: Rust ) ) ;
282
+ symbols. push ( (
283
+ ExportedSymbol :: DropGlue ( ty) ,
284
+ SymbolExportInfo {
285
+ level : SymbolExportLevel :: Rust ,
286
+ } ,
287
+ ) ) ;
258
288
}
259
289
_ => {
260
290
// Any other symbols don't qualify for sharing
0 commit comments