// 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
-
-#[inline(never)]
-fn dont_optimize<T>(x: T) -> T { x }
+#![feature(test)]
fn main() {
let b = unsafe { std::mem::transmute::<u8, bool>(2) };
- let _x = b == dont_optimize(true); //~ ERROR interpreting an invalid 8-bit value as a bool: 0x02
+ let _x = b == std::hint::black_box(true); //~ ERROR interpreting an invalid 8-bit value as a bool: 0x02
}
// compile-flags: -Zmir-opt-level=0
// FIXME: Using opt-level 2 here makes the test take forever (https://github.com/rust-lang/rust/issues/76433).
-#![feature(stmt_expr_attributes)]
+#![feature(stmt_expr_attributes, test)]
use std::fmt::Debug;
+use std::hint::black_box;
// Helper function to avoid promotion so that this tests "run-time" casts, not CTFE.
// Doesn't make a big difference when running this in Miri, but it means we can compare this
/// Tests taken from rustc test suite.
///
-// Poor-man's black-box
-#[inline(never)]
-fn black_box<T>(x: T) -> T { x }
-
macro_rules! test {
($val:expr, $src_ty:ident -> $dest_ty:ident, $expected:expr) => (
// black_box disables constant evaluation to test run-time conversions: