@@ -164,10 +164,10 @@ fn is_reachable_non_generic_provider_extern(tcx: TyCtxt<'_>, def_id: DefId) -> b
164
164
tcx. reachable_non_generics ( def_id. krate ) . contains_key ( & def_id)
165
165
}
166
166
167
- fn exported_symbols_provider_local (
168
- tcx : TyCtxt < ' _ > ,
167
+ fn exported_symbols_provider_local < ' tcx > (
168
+ tcx : TyCtxt < ' tcx > ,
169
169
_: LocalCrate ,
170
- ) -> & [ ( ExportedSymbol < ' _ > , SymbolExportInfo ) ] {
170
+ ) -> & ' tcx [ ( ExportedSymbol < ' tcx > , SymbolExportInfo ) ] {
171
171
if !tcx. sess . opts . output_types . should_codegen ( ) {
172
172
return & [ ] ;
173
173
}
@@ -341,11 +341,17 @@ fn exported_symbols_provider_local(
341
341
is_local
342
342
} ;
343
343
344
- let is_instantiable_downstream = |did, type_args| {
345
- std:: iter:: once ( tcx. type_of ( did) . skip_binder ( ) ) . chain ( type_args) . all ( |arg| {
346
- arg. walk ( ) . all ( |ty| ty. as_type ( ) . map_or ( true , |ty| !is_local_to_current_crate ( ty) ) )
347
- } )
348
- } ;
344
+ let is_instantiable_downstream =
345
+ |did : Option < DefId > , generic_args : GenericArgsRef < ' tcx > | {
346
+ generic_args
347
+ . types ( )
348
+ . chain ( did. into_iter ( ) . map ( move |did| tcx. type_of ( did) . skip_binder ( ) ) )
349
+ . all ( move |arg| {
350
+ arg. walk ( ) . all ( |ty| {
351
+ ty. as_type ( ) . map_or ( true , |ty| !is_local_to_current_crate ( ty) )
352
+ } )
353
+ } )
354
+ } ;
349
355
350
356
// The symbols created in this loop are sorted below it
351
357
#[ allow( rustc:: potential_query_instability) ]
@@ -378,7 +384,7 @@ fn exported_symbols_provider_local(
378
384
let has_generics = args. non_erasable_generics ( ) . next ( ) . is_some ( ) ;
379
385
380
386
let should_export =
381
- has_generics && is_instantiable_downstream ( def, args. types ( ) ) ;
387
+ has_generics && is_instantiable_downstream ( Some ( def) , & args) ;
382
388
383
389
if should_export {
384
390
let symbol = ExportedSymbol :: Generic ( def, args) ;
@@ -396,9 +402,10 @@ fn exported_symbols_provider_local(
396
402
// A little sanity-check
397
403
assert_eq ! ( args. non_erasable_generics( ) . next( ) , Some ( GenericArgKind :: Type ( ty) ) ) ;
398
404
405
+ // Drop glue did is always going to be non-local outside of libcore, thus we don't need to check it's locality (which includes invoking `type_of` query).
399
406
let should_export = match ty. kind ( ) {
400
- ty:: Adt ( def , args) => is_instantiable_downstream ( def . did ( ) , args. types ( ) ) ,
401
- ty:: Closure ( id , args) => is_instantiable_downstream ( * id , args. types ( ) ) ,
407
+ ty:: Adt ( _ , args) => is_instantiable_downstream ( None , args) ,
408
+ ty:: Closure ( _ , args) => is_instantiable_downstream ( None , args) ,
402
409
_ => true ,
403
410
} ;
404
411
0 commit comments