@@ -100,7 +100,6 @@ use std::fs::{self, File};
100100use std:: io:: Write ;
101101use std:: path:: { Path , PathBuf } ;
102102
103- use rustc_attr_data_structures:: InlineAttr ;
104103use rustc_data_structures:: fx:: { FxIndexMap , FxIndexSet } ;
105104use rustc_data_structures:: sync;
106105use rustc_data_structures:: unord:: { UnordMap , UnordSet } ;
@@ -210,8 +209,8 @@ where
210209 // available to downstream crates. This depends on whether we are in
211210 // share-generics mode and whether the current crate can even have
212211 // downstream crates.
213- let can_export_generics = cx . tcx . local_crate_exports_generics ( ) ;
214- let always_export_generics = can_export_generics && cx. tcx . sess . opts . share_generics ( ) ;
212+ let export_generics =
213+ cx. tcx . sess . opts . share_generics ( ) && cx . tcx . local_crate_exports_generics ( ) ;
215214
216215 let cgu_name_builder = & mut CodegenUnitNameBuilder :: new ( cx. tcx ) ;
217216 let cgu_name_cache = & mut UnordMap :: default ( ) ;
@@ -251,8 +250,7 @@ where
251250 cx. tcx ,
252251 & mono_item,
253252 & mut can_be_internalized,
254- can_export_generics,
255- always_export_generics,
253+ export_generics,
256254 ) ;
257255
258256 // We can't differentiate a function that got inlined.
@@ -747,19 +745,12 @@ fn mono_item_linkage_and_visibility<'tcx>(
747745 tcx : TyCtxt < ' tcx > ,
748746 mono_item : & MonoItem < ' tcx > ,
749747 can_be_internalized : & mut bool ,
750- can_export_generics : bool ,
751- always_export_generics : bool ,
748+ export_generics : bool ,
752749) -> ( Linkage , Visibility ) {
753750 if let Some ( explicit_linkage) = mono_item. explicit_linkage ( tcx) {
754751 return ( explicit_linkage, Visibility :: Default ) ;
755752 }
756- let vis = mono_item_visibility (
757- tcx,
758- mono_item,
759- can_be_internalized,
760- can_export_generics,
761- always_export_generics,
762- ) ;
753+ let vis = mono_item_visibility ( tcx, mono_item, can_be_internalized, export_generics) ;
763754 ( Linkage :: External , vis)
764755}
765756
@@ -782,8 +773,7 @@ fn mono_item_visibility<'tcx>(
782773 tcx : TyCtxt < ' tcx > ,
783774 mono_item : & MonoItem < ' tcx > ,
784775 can_be_internalized : & mut bool ,
785- can_export_generics : bool ,
786- always_export_generics : bool ,
776+ export_generics : bool ,
787777) -> Visibility {
788778 let instance = match mono_item {
789779 // This is pretty complicated; see below.
@@ -843,11 +833,7 @@ fn mono_item_visibility<'tcx>(
843833
844834 // Upstream `DefId` instances get different handling than local ones.
845835 let Some ( def_id) = def_id. as_local ( ) else {
846- return if is_generic
847- && ( always_export_generics
848- || ( can_export_generics
849- && tcx. codegen_fn_attrs ( def_id) . inline == InlineAttr :: Never ) )
850- {
836+ return if export_generics && is_generic {
851837 // If it is an upstream monomorphization and we export generics, we must make
852838 // it available to downstream crates.
853839 * can_be_internalized = false ;
@@ -858,9 +844,7 @@ fn mono_item_visibility<'tcx>(
858844 } ;
859845
860846 if is_generic {
861- if always_export_generics
862- || ( can_export_generics && tcx. codegen_fn_attrs ( def_id) . inline == InlineAttr :: Never )
863- {
847+ if export_generics {
864848 if tcx. is_unreachable_local_definition ( def_id) {
865849 // This instance cannot be used from another crate.
866850 Visibility :: Hidden
0 commit comments