@@ -40,6 +40,7 @@ use rustc_middle::ty::util::Discr;
4040use rustc_middle:: ty:: util:: IntTypeExt ;
4141use rustc_middle:: ty:: { self , AdtKind , Const , ToPolyTraitRef , Ty , TyCtxt } ;
4242use rustc_middle:: ty:: { ReprOptions , ToPredicate , WithConstness } ;
43+ use rustc_session:: config:: CrateType ;
4344use rustc_session:: lint;
4445use rustc_session:: parse:: feature_err;
4546use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
@@ -79,6 +80,7 @@ pub fn provide(providers: &mut Providers<'_>) {
7980 static_mutability,
8081 generator_kind,
8182 codegen_fn_attrs,
83+ inline_exportable,
8284 collect_mod_item_types,
8385 ..* providers
8486 } ;
@@ -2599,6 +2601,16 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
25992601 codegen_fn_attrs
26002602}
26012603
2604+ fn inline_exportable ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> bool {
2605+ // Functions marked with #[inline] are only ever codegened
2606+ // with "internal" linkage and are never exported unless we're
2607+ // building a `staticlib` or `cdylib` and they are marked
2608+ // `#[no_mangle]`.
2609+ tcx. codegen_fn_attrs ( def_id) . flags . contains ( CodegenFnAttrFlags :: NO_MANGLE )
2610+ && ( tcx. sess . crate_types ( ) . contains ( & CrateType :: Cdylib )
2611+ || tcx. sess . crate_types ( ) . contains ( & CrateType :: Staticlib ) )
2612+ }
2613+
26022614/// Checks if the provided DefId is a method in a trait impl for a trait which has track_caller
26032615/// applied to the method prototype.
26042616fn should_inherit_track_caller ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> bool {
0 commit comments