@@ -320,9 +320,10 @@ fn exported_symbols_provider_local(
320320 let need_visibility = tcx. sess . target . dynamic_linking && !tcx. sess . target . only_cdylib ;
321321
322322 let cgus = tcx. collect_and_partition_mono_items ( ( ) ) . codegen_units ;
323-
323+ let reachable_set = tcx . reachable_set ( ( ) ) ;
324324 let visibilities = tcx. effective_visibilities ( ( ) ) ;
325325 let is_local_to_current_crate = |ty : Ty < ' _ > | {
326+
326327 let no_refs = ty. peel_refs ( ) ;
327328 let root_def_id = match no_refs. kind ( ) {
328329 rustc_middle:: ty:: Adt ( adt_def, _) => adt_def. did ( ) ,
@@ -340,8 +341,7 @@ fn exported_symbols_provider_local(
340341 return false ;
341342 } ;
342343
343- let is_local = visibilities. public_at_level ( root_def_id) . is_none ( ) ;
344-
344+ let is_local = !reachable_set. contains ( & root_def_id) ;
345345 is_local
346346 } ;
347347 // The symbols created in this loop are sorted below it
@@ -366,21 +366,22 @@ fn exported_symbols_provider_local(
366366 // this is OK, we explicitly allow sharing inline(never) across crates even
367367 // without share-generics.
368368 } else {
369+
369370 continue ;
370371 }
371372 }
372373
373374 match * mono_item {
374375 MonoItem :: Fn ( Instance { def : InstanceKind :: Item ( def) , args } ) => {
375- let mut types = args. types ( ) ;
376+ let types = args. types ( ) ;
376377 let has_generics = args. non_erasable_generics ( ) . next ( ) . is_some ( ) ;
378+
377379 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
381381 != rustc_attr_parsing:: InlineAttr :: None )
382- || types. all ( |arg| {
382+ || Some ( tcx . type_of ( def ) . skip_binder ( ) ) . into_iter ( ) . chain ( types) . all ( |arg| {
383383 arg. walk ( ) . all ( |ty| {
384+
384385 let Some ( ty) = ty. as_type ( ) else {
385386 return true ;
386387 } ;
0 commit comments