Stabilize const_black_box
This has been unstably const since [1], but a tracking issue was never created. Per discussion on Zulip [2], there should not be any blockers to making this const-stable. The function does not provide any functionality at compile time but does allow code reuse between const- and non-const functions, so stabilize it here. [1]: https://github.com/rust-lang/rust/pull/92226 [2]: https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/const_black_box
This commit is contained in:
parent
633a3fe36d
commit
395f0c9ecd
4 changed files with 4 additions and 4 deletions
|
@ -3,8 +3,6 @@
|
||||||
// Run-time:
|
// Run-time:
|
||||||
// status: 0
|
// status: 0
|
||||||
|
|
||||||
#![feature(const_black_box)]
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Code
|
* Code
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -468,9 +468,11 @@ pub fn spin_loop() {
|
||||||
/// // No assumptions can be made about either operand, so the multiplication is not optimized out.
|
/// // No assumptions can be made about either operand, so the multiplication is not optimized out.
|
||||||
/// let y = black_box(5) * black_box(10);
|
/// let y = black_box(5) * black_box(10);
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// During constant evaluation, `black_box` is treated as a no-op.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "bench_black_box", since = "1.66.0")]
|
#[stable(feature = "bench_black_box", since = "1.66.0")]
|
||||||
#[rustc_const_unstable(feature = "const_black_box", issue = "none")]
|
#[rustc_const_stable(feature = "const_black_box", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub const fn black_box<T>(dummy: T) -> T {
|
pub const fn black_box<T>(dummy: T) -> T {
|
||||||
crate::intrinsics::black_box(dummy)
|
crate::intrinsics::black_box(dummy)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3725,6 +3725,7 @@ pub const unsafe fn compare_bytes(_left: *const u8, _right: *const u8, _bytes: u
|
||||||
#[rustc_nounwind]
|
#[rustc_nounwind]
|
||||||
#[rustc_intrinsic]
|
#[rustc_intrinsic]
|
||||||
#[rustc_intrinsic_must_be_overridden]
|
#[rustc_intrinsic_must_be_overridden]
|
||||||
|
#[rustc_intrinsic_const_stable_indirect]
|
||||||
pub const fn black_box<T>(_dummy: T) -> T {
|
pub const fn black_box<T>(_dummy: T) -> T {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#![feature(bstr)]
|
#![feature(bstr)]
|
||||||
#![feature(cell_update)]
|
#![feature(cell_update)]
|
||||||
#![feature(clone_to_uninit)]
|
#![feature(clone_to_uninit)]
|
||||||
#![feature(const_black_box)]
|
|
||||||
#![feature(const_eval_select)]
|
#![feature(const_eval_select)]
|
||||||
#![feature(const_swap_nonoverlapping)]
|
#![feature(const_swap_nonoverlapping)]
|
||||||
#![feature(const_trait_impl)]
|
#![feature(const_trait_impl)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue