File tree Expand file tree Collapse file tree 3 files changed +6
-10
lines changed Expand file tree Collapse file tree 3 files changed +6
-10
lines changed Original file line number Diff line number Diff line change 11// Validation makes this fail in the wrong place
22// Make sure we find these even with many checks disabled.
33// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
4-
5- #[ inline( never) ]
6- fn dont_optimize < T > ( x : T ) -> T { x }
4+ #![ feature( test) ]
75
86fn main ( ) {
97 let b = unsafe { std:: mem:: transmute :: < u8 , bool > ( 2 ) } ;
10- let _x = b == dont_optimize ( true ) ; //~ ERROR interpreting an invalid 8-bit value as a bool: 0x02
8+ let _x = b == std :: hint :: black_box ( true ) ; //~ ERROR interpreting an invalid 8-bit value as a bool: 0x02
119}
Original file line number Diff line number Diff line change 11// compile-flags: -Zmir-opt-level=0
22// FIXME: Using opt-level 2 here makes the test take forever (https://github.com/rust-lang/rust/issues/76433).
3- #![ feature( stmt_expr_attributes) ]
3+ #![ feature( stmt_expr_attributes, test ) ]
44use std:: fmt:: Debug ;
5+ use std:: hint:: black_box;
56
67// Helper function to avoid promotion so that this tests "run-time" casts, not CTFE.
78// Doesn't make a big difference when running this in Miri, but it means we can compare this
@@ -341,10 +342,6 @@ fn ops() {
341342/// Tests taken from rustc test suite.
342343///
343344
344- // Poor-man's black-box
345- #[ inline( never) ]
346- fn black_box < T > ( x : T ) -> T { x }
347-
348345macro_rules! test {
349346 ( $val: expr, $src_ty: ident -> $dest_ty: ident, $expected: expr) => (
350347 // black_box disables constant evaluation to test run-time conversions:
Original file line number Diff line number Diff line change 1- fn b < T > ( t : T ) -> T { t }
1+ #![ feature( test) ]
2+ use std:: hint:: black_box as b;
23
34fn main ( ) {
45 let x: u128 = 0xFFFF_FFFF_FFFF_FFFF__FFFF_FFFF_FFFF_FFFF ;
You can’t perform that action at this time.
0 commit comments