rustc_middle/ty/
intrinsic.rs

1use rustc_macros::{Decodable, Encodable, HashStable};
2use rustc_span::Symbol;
3use rustc_span::def_id::DefId;
4
5use super::TyCtxt;
6
7#[derive(Copy, Clone, Debug, Decodable, Encodable, HashStable)]
8pub struct IntrinsicDef {
9    pub name: Symbol,
10    /// Whether the intrinsic has no meaningful body and all backends need to shim all calls to it.
11    pub must_be_overridden: bool,
12    /// Whether the intrinsic can be invoked from stable const fn
13    pub const_stable: bool,
14}
15
16impl TyCtxt<'_> {
17    pub fn is_intrinsic(self, def_id: DefId, name: Symbol) -> bool {
18        let Some(i) = self.intrinsic(def_id) else { return false };
19        i.name == name
20    }
21}