Honor allow_internal_unstable for const intrinsics.
This commit is contained in:
parent
72444372ae
commit
12e91cf814
2 changed files with 10 additions and 4 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -2802,7 +2802,6 @@ pub const fn align_of<T>() -> 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"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue