@@ -100,7 +100,6 @@ use std::fs::{self, File};
100
100
use std:: io:: Write ;
101
101
use std:: path:: { Path , PathBuf } ;
102
102
103
- use rustc_attr_data_structures:: InlineAttr ;
104
103
use rustc_data_structures:: fx:: { FxIndexMap , FxIndexSet } ;
105
104
use rustc_data_structures:: sync;
106
105
use rustc_data_structures:: unord:: { UnordMap , UnordSet } ;
@@ -210,8 +209,8 @@ where
210
209
// available to downstream crates. This depends on whether we are in
211
210
// share-generics mode and whether the current crate can even have
212
211
// 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 ( ) ;
215
214
216
215
let cgu_name_builder = & mut CodegenUnitNameBuilder :: new ( cx. tcx ) ;
217
216
let cgu_name_cache = & mut UnordMap :: default ( ) ;
@@ -251,8 +250,7 @@ where
251
250
cx. tcx ,
252
251
& mono_item,
253
252
& mut can_be_internalized,
254
- can_export_generics,
255
- always_export_generics,
253
+ export_generics,
256
254
) ;
257
255
258
256
// We can't differentiate a function that got inlined.
@@ -747,19 +745,12 @@ fn mono_item_linkage_and_visibility<'tcx>(
747
745
tcx : TyCtxt < ' tcx > ,
748
746
mono_item : & MonoItem < ' tcx > ,
749
747
can_be_internalized : & mut bool ,
750
- can_export_generics : bool ,
751
- always_export_generics : bool ,
748
+ export_generics : bool ,
752
749
) -> ( Linkage , Visibility ) {
753
750
if let Some ( explicit_linkage) = mono_item. explicit_linkage ( tcx) {
754
751
return ( explicit_linkage, Visibility :: Default ) ;
755
752
}
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) ;
763
754
( Linkage :: External , vis)
764
755
}
765
756
@@ -782,8 +773,7 @@ fn mono_item_visibility<'tcx>(
782
773
tcx : TyCtxt < ' tcx > ,
783
774
mono_item : & MonoItem < ' tcx > ,
784
775
can_be_internalized : & mut bool ,
785
- can_export_generics : bool ,
786
- always_export_generics : bool ,
776
+ export_generics : bool ,
787
777
) -> Visibility {
788
778
let instance = match mono_item {
789
779
// This is pretty complicated; see below.
@@ -843,11 +833,7 @@ fn mono_item_visibility<'tcx>(
843
833
844
834
// Upstream `DefId` instances get different handling than local ones.
845
835
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 {
851
837
// If it is an upstream monomorphization and we export generics, we must make
852
838
// it available to downstream crates.
853
839
* can_be_internalized = false ;
@@ -858,9 +844,7 @@ fn mono_item_visibility<'tcx>(
858
844
} ;
859
845
860
846
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 {
864
848
if tcx. is_unreachable_local_definition ( def_id) {
865
849
// This instance cannot be used from another crate.
866
850
Visibility :: Hidden
0 commit comments