Skip to content

Commit

Permalink
Rollup merge of #102232 - Urgau:stabilize-bench_black_box, r=TaKO8Ki
Browse files Browse the repository at this point in the history
Stabilize bench_black_box

This PR stabilize `feature(bench_black_box)`.

```rust
pub fn black_box<T>(dummy: T) -> T;
```

The FCP was completed in #64102.

`@rustbot` label +T-libs-api -T-libs
  • Loading branch information
JohnTitor authored Sep 28, 2022
2 parents 49bc668 + 9ad2f00 commit 07bb2e6
Show file tree
Hide file tree
Showing 23 changed files with 8 additions and 28 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/example/std_example.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(core_intrinsics, generators, generator_trait, is_sorted, bench_black_box)]
#![feature(core_intrinsics, generators, generator_trait, is_sorted)]

#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::*;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/tests/run/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Run-time:
// status: 0

#![feature(bench_black_box, const_black_box, core_intrinsics, start)]
#![feature(const_black_box, core_intrinsics, start)]

#![no_std]

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_index/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
#![feature(allow_internal_unstable)]
#![feature(bench_black_box)]
#![feature(extend_one)]
#![feature(min_specialization)]
#![feature(new_uninit)]
Expand Down
1 change: 0 additions & 1 deletion library/alloc/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#![feature(pointer_is_aligned)]
#![feature(slice_flatten)]
#![feature(thin_box)]
#![feature(bench_black_box)]
#![feature(strict_provenance)]
#![feature(once_cell)]
#![feature(drain_keep_rest)]
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ pub fn spin_loop() {
///
/// [`std::convert::identity`]: crate::convert::identity
#[inline]
#[unstable(feature = "bench_black_box", issue = "64102")]
#[stable(feature = "bench_black_box", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_unstable(feature = "const_black_box", issue = "none")]
pub const fn black_box<T>(dummy: T) -> T {
crate::intrinsics::black_box(dummy)
Expand Down
1 change: 0 additions & 1 deletion library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#![feature(array_chunks)]
#![feature(array_methods)]
#![feature(array_windows)]
#![feature(bench_black_box)]
#![feature(bigint_helper_methods)]
#![feature(cell_update)]
#![feature(const_assume)]
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@
#![feature(trace_macros)]
//
// Only used in tests/benchmarks:
#![feature(bench_black_box)]
//
// Only for const-ness:
#![feature(const_io_structs)]
Expand Down
1 change: 0 additions & 1 deletion library/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#![unstable(feature = "test", issue = "50297")]
#![doc(test(attr(deny(warnings))))]
#![feature(bench_black_box)]
#![feature(internal_output_capture)]
#![feature(staged_api)]
#![feature(process_exitcode_internals)]
Expand Down
1 change: 0 additions & 1 deletion src/test/incremental/spans_significant_w_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// compile-flags: -C overflow-checks=on -Z query-dep-graph

#![feature(rustc_attrs)]
#![feature(bench_black_box)]
#![rustc_partition_codegened(module = "spans_significant_w_panic", cfg = "rpass2")]
#![rustc_partition_codegened(module = "spans_significant_w_panic", cfg = "rpass4")]

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/box/issue-95036.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// compile-flags: -O
// build-pass

#![feature(allocator_api, bench_black_box)]
#![feature(allocator_api)]

#[inline(never)]
pub fn by_ref(node: &mut Box<[u8; 1], &std::alloc::Global>) {
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/consts/cast-discriminant-zst-enum.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
// Test a ZST enum whose dicriminant is ~0i128. This caused an ICE when casting to an i32.
#![feature(bench_black_box)]
use std::hint::black_box;

#[derive(Copy, Clone)]
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/consts/const_discriminant.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
#![feature(const_discriminant)]
#![feature(bench_black_box)]
#![allow(dead_code)]

use std::mem::{discriminant, Discriminant};
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-99838.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// run-pass
#![feature(bench_black_box)]

use std::hint;

struct U16(u16);
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/oom_unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// needs-unwind
// only-linux

#![feature(bench_black_box)]

use std::hint::black_box;
use std::mem::forget;
use std::panic::catch_unwind;
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/process/process-panic-after-fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// ignore-sgx no processes
// ignore-android: FIXME(#85261)

#![feature(bench_black_box)]
#![feature(rustc_private)]
#![feature(never_type)]
#![feature(panic_always_abort)]
Expand Down
4 changes: 1 addition & 3 deletions src/test/ui/sanitize/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
//
// run-fail
// error-pattern: AddressSanitizer: stack-buffer-overflow
// error-pattern: 'xs' (line 15) <== Memory access at offset

#![feature(bench_black_box)]
// error-pattern: 'xs' (line 13) <== Memory access at offset

use std::hint::black_box;

Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/sanitize/hwaddress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
// run-fail
// error-pattern: HWAddressSanitizer: tag-mismatch

#![feature(bench_black_box)]

use std::hint::black_box;

fn main() {
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/sanitize/leak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
// run-fail
// error-pattern: LeakSanitizer: detected memory leaks

#![feature(bench_black_box)]

use std::hint::black_box;
use std::mem;

Expand Down
1 change: 0 additions & 1 deletion src/test/ui/sanitize/memory-eager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#![feature(core_intrinsics)]
#![feature(start)]
#![feature(bench_black_box)]

use std::hint::black_box;
use std::mem::MaybeUninit;
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/sanitize/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#![feature(core_intrinsics)]
#![feature(start)]
#![feature(bench_black_box)]
#![allow(invalid_value)]

use std::hint::black_box;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/tests/fail/invalid_bool.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Validation makes this fail in the wrong place
// Make sure we find these even with many checks disabled.
//@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
#![feature(bench_black_box)]


fn main() {
let b = unsafe { std::mem::transmute::<u8, bool>(2) };
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/tests/pass/float.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(stmt_expr_attributes, bench_black_box)]
#![feature(stmt_expr_attributes)]
#![allow(arithmetic_overflow)]
use std::fmt::Debug;
use std::hint::black_box;
Expand Down
1 change: 0 additions & 1 deletion src/tools/miri/tests/pass/u128.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(bench_black_box)]
use std::hint::black_box as b;

fn main() {
Expand Down

0 comments on commit 07bb2e6

Please sign in to comment.