Skip to content

Commit b249760

Browse files
authored
Rollup merge of rust-lang#135414 - tgross35:stabilize-const_black_box, r=dtolnay
Stabilize `const_black_box` This has been unstably const since rust-lang#92226, but a tracking issue was never created. Per [discussion on Zulip][zulip], 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. [zulip]: https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/const_black_box
2 parents 6c1d960 + 395f0c9 commit b249760

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

compiler/rustc_codegen_gcc/tests/run/int.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// Run-time:
44
// status: 0
55

6-
#![feature(const_black_box)]
7-
86
/*
97
* Code
108
*/

library/core/src/hint.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,11 @@ pub fn spin_loop() {
468468
/// // No assumptions can be made about either operand, so the multiplication is not optimized out.
469469
/// let y = black_box(5) * black_box(10);
470470
/// ```
471+
///
472+
/// During constant evaluation, `black_box` is treated as a no-op.
471473
#[inline]
472474
#[stable(feature = "bench_black_box", since = "1.66.0")]
473-
#[rustc_const_unstable(feature = "const_black_box", issue = "none")]
475+
#[rustc_const_stable(feature = "const_black_box", since = "CURRENT_RUSTC_VERSION")]
474476
pub const fn black_box<T>(dummy: T) -> T {
475477
crate::intrinsics::black_box(dummy)
476478
}

library/core/src/intrinsics/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3725,6 +3725,7 @@ pub const unsafe fn compare_bytes(_left: *const u8, _right: *const u8, _bytes: u
37253725
#[rustc_nounwind]
37263726
#[rustc_intrinsic]
37273727
#[rustc_intrinsic_must_be_overridden]
3728+
#[rustc_intrinsic_const_stable_indirect]
37283729
pub const fn black_box<T>(_dummy: T) -> T {
37293730
unimplemented!()
37303731
}

library/coretests/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#![feature(bstr)]
1515
#![feature(cell_update)]
1616
#![feature(clone_to_uninit)]
17-
#![feature(const_black_box)]
1817
#![feature(const_eval_select)]
1918
#![feature(const_swap_nonoverlapping)]
2019
#![feature(const_trait_impl)]

0 commit comments

Comments
 (0)