1
Fork 0

add new rustc_const_stable_intrinsic attribute for const-stable intrinsics

This commit is contained in:
Ralf Jung 2024-11-01 22:53:59 +01:00
parent 10723c2896
commit 1f0ed2b0f5
9 changed files with 80 additions and 68 deletions

View file

@ -9,6 +9,8 @@ pub struct IntrinsicDef {
pub name: Symbol,
/// Whether the intrinsic has no meaningful body and all backends need to shim all calls to it.
pub must_be_overridden: bool,
/// Whether the intrinsic can be invoked from stable const fn
pub const_stable: bool,
}
impl TyCtxt<'_> {

View file

@ -1789,6 +1789,8 @@ pub fn intrinsic_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ty::Intrinsi
Some(ty::IntrinsicDef {
name: tcx.item_name(def_id.into()),
must_be_overridden: tcx.has_attr(def_id, sym::rustc_intrinsic_must_be_overridden),
const_stable: tcx.has_attr(def_id, sym::rustc_const_stable_intrinsic)
|| tcx.lookup_const_stability(def_id).is_some_and(|s| s.is_const_stable()),
})
} else {
None