diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs index 4110317adcf4..66a2afa0aa7d 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -853,9 +853,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { } // Intrinsics are language primitives, not regular calls, so treat them separately. - if let Some(intrinsic) = tcx.intrinsic(callee) - && intrinsic.name != sym::offset_of - { + if let Some(intrinsic) = tcx.intrinsic(callee) { if !tcx.is_const_fn(callee) { // Non-const intrinsic. self.check_op(ops::IntrinsicNonConst { name: intrinsic.name }); @@ -888,6 +886,15 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { feature, .. }) => { + // We only honor `span.allows_unstable` aka `#[allow_internal_unstable]` + // if the callee is safe to expose, to avoid bypassing recursive stability. + // This is not ideal since it means the user sees an error, not the macro + // author, but that's also the case if one forgets to set + // `#[allow_internal_unstable]` in the first place. + if self.span.allows_unstable(feature) && is_const_stable { + return; + } + self.check_op(ops::IntrinsicUnstable { name: intrinsic.name, feature, diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 18d8b9880dfa..374c749c2da0 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -2802,7 +2802,6 @@ pub const fn align_of() -> usize; #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_const_unstable(feature = "core_intrinsics", issue = "none")] -#[rustc_const_stable_indirect] #[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] #[lang = "offset_of"]