Skip to content

Commit d76f61a

Browse files
committed
Querify should_codegen_locally
1 parent a00df61 commit d76f61a

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

compiler/rustc_middle/src/hooks/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ declare_hooks! {
104104

105105
/// Create a list-like THIR representation for debugging.
106106
hook thir_flat(key: LocalDefId) -> String;
107-
108-
/// Returns `true` if we should codegen an instance in the local crate, or returns `false` if we
109-
/// can just link to the upstream crate and therefore don't need a mono item.
110-
hook should_codegen_locally(instance: crate::ty::Instance<'tcx>) -> bool;
111107
}
112108

113109
#[cold]

compiler/rustc_middle/src/query/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,11 @@ rustc_queries! {
16341634
separate_provide_extern
16351635
}
16361636

1637+
query should_codegen_locally(key: ty::Instance<'tcx>) -> bool {
1638+
desc { "checking whether `{}` should be linked to or lowered", key }
1639+
cache_on_disk_if { true }
1640+
}
1641+
16371642
/// Returns the upstream crate that exports drop-glue for the given
16381643
/// type (`args` is expected to be a single-item list containing the
16391644
/// type one wants drop-glue for).

compiler/rustc_monomorphize/src/collector.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ fn visit_instance_use<'tcx>(
921921

922922
/// Returns `true` if we should codegen an instance in the local crate, or returns `false` if we
923923
/// can just link to the upstream crate and therefore don't need a mono item.
924-
fn should_codegen_locally<'tcx>(tcx: TyCtxtAt<'tcx>, instance: Instance<'tcx>) -> bool {
924+
fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> bool {
925925
let Some(def_id) = instance.def.def_id_if_not_guaranteed_local_codegen() else {
926926
return true;
927927
};
@@ -937,7 +937,7 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxtAt<'tcx>, instance: Instance<'tcx>) -
937937
}
938938

939939
if tcx.is_reachable_non_generic(def_id)
940-
|| instance.polymorphize(*tcx).upstream_monomorphization(*tcx).is_some()
940+
|| instance.polymorphize(tcx).upstream_monomorphization(tcx).is_some()
941941
{
942942
// We can link to the item in question, no instance needed in this crate.
943943
return false;
@@ -1595,5 +1595,5 @@ pub(crate) fn collect_crate_mono_items<'tcx>(
15951595
}
15961596

15971597
pub(crate) fn provide(providers: &mut Providers) {
1598-
providers.hooks.should_codegen_locally = should_codegen_locally;
1598+
providers.should_codegen_locally = should_codegen_locally;
15991599
}

0 commit comments

Comments
 (0)