mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Auto merge of #122010 - oli-obk:intrinsics3.0, r=pnkfelix
Avoid invoking the `intrinsic` query for DefKinds other than `Fn` or `AssocFn` fixes the perf regression from https://github.com/rust-lang/rust/pull/120675 by only invoking (and thus inserting into the dep graph) the `intrinsic` query if the `DefKind` matches items that can actually be intrinsics
This commit is contained in:
commit
4d4bb491b6
@ -356,7 +356,7 @@ provide! { tcx, def_id, other, cdata,
|
||||
cdata.get_stability_implications(tcx).iter().copied().collect()
|
||||
}
|
||||
stripped_cfg_items => { cdata.get_stripped_cfg_items(cdata.cnum, tcx) }
|
||||
intrinsic => { cdata.get_intrinsic(def_id.index) }
|
||||
intrinsic_raw => { cdata.get_intrinsic(def_id.index) }
|
||||
defined_lang_items => { cdata.get_lang_items(tcx) }
|
||||
diagnostic_items => { cdata.get_diagnostic_items() }
|
||||
missing_lang_items => { cdata.get_missing_lang_items(tcx) }
|
||||
|
@ -1742,7 +1742,7 @@ rustc_queries! {
|
||||
separate_provide_extern
|
||||
}
|
||||
/// Whether the function is an intrinsic
|
||||
query intrinsic(def_id: DefId) -> Option<rustc_middle::ty::IntrinsicDef> {
|
||||
query intrinsic_raw(def_id: DefId) -> Option<rustc_middle::ty::IntrinsicDef> {
|
||||
desc { |tcx| "fetch intrinsic name if `{}` is an intrinsic", tcx.def_path_str(def_id) }
|
||||
separate_provide_extern
|
||||
}
|
||||
|
@ -2334,6 +2334,14 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn intrinsic(self, def_id: impl IntoQueryParam<DefId> + Copy) -> Option<ty::IntrinsicDef> {
|
||||
match self.def_kind(def_id) {
|
||||
DefKind::Fn | DefKind::AssocFn => {}
|
||||
_ => return None,
|
||||
}
|
||||
self.intrinsic_raw(def_id)
|
||||
}
|
||||
|
||||
pub fn local_def_id_to_hir_id(self, local_def_id: LocalDefId) -> HirId {
|
||||
self.opt_local_def_id_to_hir_id(local_def_id).unwrap()
|
||||
}
|
||||
|
@ -1642,11 +1642,7 @@ pub fn is_doc_notable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
}
|
||||
|
||||
/// Determines whether an item is an intrinsic (which may be via Abi or via the `rustc_intrinsic` attribute)
|
||||
pub fn intrinsic(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ty::IntrinsicDef> {
|
||||
match tcx.def_kind(def_id) {
|
||||
DefKind::Fn | DefKind::AssocFn => {}
|
||||
_ => return None,
|
||||
}
|
||||
pub fn intrinsic_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ty::IntrinsicDef> {
|
||||
if matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic)
|
||||
|| tcx.has_attr(def_id, sym::rustc_intrinsic)
|
||||
{
|
||||
@ -1664,7 +1660,7 @@ pub fn provide(providers: &mut Providers) {
|
||||
reveal_opaque_types_in_bounds,
|
||||
is_doc_hidden,
|
||||
is_doc_notable_trait,
|
||||
intrinsic,
|
||||
intrinsic_raw,
|
||||
..*providers
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user