Rollup merge of #132449 - RalfJung:is_val_statically_known, r=compiler-errors

mark is_val_statically_known intrinsic as stably const-callable

The intrinsic doesn't actually "do" anything in terms of language semantics, and we are already using it in stable const fn. So let's just properly mark it as stably const-callable to avoid needing `rustc_allow_const_fn_unstable` (and thus reducing noise and keeping the remaining `rustc_allow_const_fn_unstable` as a more clear signal).

Cc `@rust-lang/lang` usually you have to approve exposing intrinsics in const, but this intrinsic is basically just a compiler implementation detail. So FCP doesn't seem necessary.
Cc `@rust-lang/wg-const-eval`
This commit is contained in:
Matthias Krüger 2024-11-16 21:05:44 +01:00 committed by GitHub
commit fb5bd7ffcc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 6 additions and 10 deletions

View File

@ -3535,7 +3535,6 @@ pub(crate) macro const_eval_select {
/// In other words, the following code has *Undefined Behavior*:
///
/// ```no_run
/// #![feature(is_val_statically_known)]
/// #![feature(core_intrinsics)]
/// # #![allow(internal_features)]
/// use std::hint::unreachable_unchecked;
@ -3548,7 +3547,6 @@ pub(crate) macro const_eval_select {
/// may panic, or it may not:
///
/// ```no_run
/// #![feature(is_val_statically_known)]
/// #![feature(core_intrinsics)]
/// # #![allow(internal_features)]
/// use std::intrinsics::is_val_statically_known;
@ -3581,7 +3579,6 @@ pub(crate) macro const_eval_select {
/// behave identically:
///
/// ```
/// #![feature(is_val_statically_known)]
/// #![feature(core_intrinsics)]
/// # #![allow(internal_features)]
/// use std::intrinsics::is_val_statically_known;
@ -3598,7 +3595,11 @@ pub(crate) macro const_eval_select {
/// # _ = foo(&5_i32);
/// # _ = bar(&5_i32);
/// ```
#[rustc_const_unstable(feature = "is_val_statically_known", issue = "none")]
#[cfg_attr(
bootstrap,
rustc_const_stable(feature = "const_is_val_statically_known", since = "CURRENT_RUSTC_VERSION")
)]
#[cfg_attr(not(bootstrap), rustc_const_stable_indirect)]
#[rustc_nounwind]
#[unstable(feature = "core_intrinsics", issue = "none")]
#[rustc_intrinsic]

View File

@ -139,7 +139,6 @@
#![feature(internal_impls_macro)]
#![feature(ip)]
#![feature(is_ascii_octdigit)]
#![feature(is_val_statically_known)]
#![feature(lazy_get)]
#![feature(link_cfg)]
#![feature(non_null_from_ref)]

View File

@ -2242,7 +2242,6 @@ macro_rules! int_impl {
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
#[rustc_allow_const_fn_unstable(is_val_statically_known)]
pub const fn wrapping_pow(self, mut exp: u32) -> Self {
if exp == 0 {
return 1;
@ -2808,7 +2807,6 @@ macro_rules! int_impl {
without modifying the original"]
#[inline]
#[rustc_inherit_overflow_checks]
#[rustc_allow_const_fn_unstable(is_val_statically_known)]
pub const fn pow(self, mut exp: u32) -> Self {
if exp == 0 {
return 1;

View File

@ -2251,7 +2251,6 @@ macro_rules! uint_impl {
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
#[rustc_allow_const_fn_unstable(is_val_statically_known)]
pub const fn wrapping_pow(self, mut exp: u32) -> Self {
if exp == 0 {
return 1;
@ -2791,7 +2790,6 @@ macro_rules! uint_impl {
without modifying the original"]
#[inline]
#[rustc_inherit_overflow_checks]
#[rustc_allow_const_fn_unstable(is_val_statically_known)]
pub const fn pow(self, mut exp: u32) -> Self {
if exp == 0 {
return 1;

View File

@ -1,6 +1,6 @@
//@ run-pass
#![feature(core_intrinsics, is_val_statically_known)]
#![feature(core_intrinsics)]
use std::intrinsics::is_val_statically_known;