diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index bc2209751cac..7a60946069b8 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -1643,7 +1643,11 @@ 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 { - if matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic | Abi::PlatformIntrinsic) + if (matches!(tcx.def_kind(def_id), DefKind::Fn) + && matches!( + tcx.fn_sig(def_id).skip_binder().abi(), + Abi::RustIntrinsic | Abi::PlatformIntrinsic + )) || tcx.has_attr(def_id, sym::rustc_intrinsic) { Some(ty::IntrinsicDef {