@@ -228,6 +228,7 @@ use rustc_middle::ty::{
228
228
self , AssocKind , GenericParamDefKind , Instance , InstanceKind , Ty , TyCtxt , TypeFoldable ,
229
229
TypeVisitableExt , VtblEntry ,
230
230
} ;
231
+ use rustc_middle:: util:: Providers ;
231
232
use rustc_middle:: { bug, span_bug} ;
232
233
use rustc_session:: config:: EntryFnType ;
233
234
use rustc_session:: Limit ;
@@ -930,7 +931,7 @@ fn visit_instance_use<'tcx>(
930
931
931
932
/// Returns `true` if we should codegen an instance in the local crate, or returns `false` if we
932
933
/// 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 {
934
935
let Some ( def_id) = instance. def . def_id_if_not_guaranteed_local_codegen ( ) else {
935
936
return true ;
936
937
} ;
@@ -946,7 +947,7 @@ pub(crate) fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance
946
947
}
947
948
948
949
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 ( )
950
951
{
951
952
// We can link to the item in question, no instance needed in this crate.
952
953
return false ;
@@ -967,6 +968,12 @@ pub(crate) fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance
967
968
true
968
969
}
969
970
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
+
970
977
/// For a given pair of source and target type that occur in an unsizing coercion,
971
978
/// this function finds the pair of types that determines the vtable linking
972
979
/// them.
@@ -1613,3 +1620,7 @@ pub(crate) fn collect_crate_mono_items<'tcx>(
1613
1620
1614
1621
( mono_items, state. usage_map . into_inner ( ) )
1615
1622
}
1623
+
1624
+ pub fn provide ( providers : & mut Providers ) {
1625
+ providers. hooks . should_codegen_locally = should_codegen_locally_hook;
1626
+ }
0 commit comments