@@ -320,9 +320,10 @@ fn exported_symbols_provider_local(
320
320
let need_visibility = tcx. sess . target . dynamic_linking && !tcx. sess . target . only_cdylib ;
321
321
322
322
let cgus = tcx. collect_and_partition_mono_items ( ( ) ) . codegen_units ;
323
-
323
+ let reachable_set = tcx . reachable_set ( ( ) ) ;
324
324
let visibilities = tcx. effective_visibilities ( ( ) ) ;
325
325
let is_local_to_current_crate = |ty : Ty < ' _ > | {
326
+
326
327
let no_refs = ty. peel_refs ( ) ;
327
328
let root_def_id = match no_refs. kind ( ) {
328
329
rustc_middle:: ty:: Adt ( adt_def, _) => adt_def. did ( ) ,
@@ -340,8 +341,7 @@ fn exported_symbols_provider_local(
340
341
return false ;
341
342
} ;
342
343
343
- let is_local = visibilities. public_at_level ( root_def_id) . is_none ( ) ;
344
-
344
+ let is_local = !reachable_set. contains ( & root_def_id) ;
345
345
is_local
346
346
} ;
347
347
// The symbols created in this loop are sorted below it
@@ -366,21 +366,22 @@ fn exported_symbols_provider_local(
366
366
// this is OK, we explicitly allow sharing inline(never) across crates even
367
367
// without share-generics.
368
368
} else {
369
+
369
370
continue ;
370
371
}
371
372
}
372
373
373
374
match * mono_item {
374
375
MonoItem :: Fn ( Instance { def : InstanceKind :: Item ( def) , args } ) => {
375
- let mut types = args. types ( ) ;
376
+ let types = args. types ( ) ;
376
377
let has_generics = args. non_erasable_generics ( ) . next ( ) . is_some ( ) ;
378
+
377
379
let should_export = has_generics
378
- && ( def. as_local ( ) . is_some_and ( |local_did| {
379
- visibilities. public_at_level ( local_did) . is_some ( )
380
- } ) || ( tcx. codegen_fn_attrs ( mono_item. def_id ( ) ) . inline
380
+ && ( ( tcx. codegen_fn_attrs ( mono_item. def_id ( ) ) . inline
381
381
!= rustc_attr_parsing:: InlineAttr :: None )
382
- || types. all ( |arg| {
382
+ || Some ( tcx . type_of ( def ) . skip_binder ( ) ) . into_iter ( ) . chain ( types) . all ( |arg| {
383
383
arg. walk ( ) . all ( |ty| {
384
+
384
385
let Some ( ty) = ty. as_type ( ) else {
385
386
return true ;
386
387
} ;
0 commit comments