@@ -228,6 +228,7 @@ use rustc_middle::ty::{
228228 self , AssocKind , GenericParamDefKind , Instance , InstanceKind , Ty , TyCtxt , TypeFoldable ,
229229 TypeVisitableExt , VtblEntry ,
230230} ;
231+ use rustc_middle:: util:: Providers ;
231232use rustc_middle:: { bug, span_bug} ;
232233use rustc_session:: config:: EntryFnType ;
233234use rustc_session:: Limit ;
@@ -930,7 +931,7 @@ fn visit_instance_use<'tcx>(
930931
931932/// Returns `true` if we should codegen an instance in the local crate, or returns `false` if we
932933/// can just link to the upstream crate and therefore don't need a mono item.
933- pub ( crate ) fn should_codegen_locally < ' tcx > ( tcx : TyCtxt < ' tcx > , instance : Instance < ' tcx > ) -> bool {
934+ pub ( crate ) fn should_codegen_locally_hook < ' tcx > ( tcx : TyCtxtAt < ' tcx > , instance : Instance < ' tcx > ) -> bool {
934935 let Some ( def_id) = instance. def . def_id_if_not_guaranteed_local_codegen ( ) else {
935936 return true ;
936937 } ;
@@ -946,7 +947,7 @@ pub(crate) fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance
946947 }
947948
948949 if tcx. is_reachable_non_generic ( def_id)
949- || instance. polymorphize ( tcx) . upstream_monomorphization ( tcx) . is_some ( )
950+ || instance. polymorphize ( * tcx) . upstream_monomorphization ( * tcx) . is_some ( )
950951 {
951952 // We can link to the item in question, no instance needed in this crate.
952953 return false ;
@@ -967,6 +968,12 @@ pub(crate) fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance
967968 true
968969}
969970
971+ /// Returns `true` if we should codegen an instance in the local crate, or returns `false` if we
972+ /// can just link to the upstream crate and therefore don't need a mono item.
973+ pub ( crate ) fn should_codegen_locally < ' tcx > ( tcx : TyCtxt < ' tcx > , instance : Instance < ' tcx > ) -> bool {
974+ tcx. should_codegen_locally ( instance)
975+ }
976+
970977/// For a given pair of source and target type that occur in an unsizing coercion,
971978/// this function finds the pair of types that determines the vtable linking
972979/// them.
@@ -1613,3 +1620,7 @@ pub(crate) fn collect_crate_mono_items<'tcx>(
16131620
16141621 ( mono_items, state. usage_map . into_inner ( ) )
16151622}
1623+
1624+ pub fn provide ( providers : & mut Providers ) {
1625+ providers. hooks . should_codegen_locally = should_codegen_locally_hook;
1626+ }
0 commit comments