Skip to content

Commit bb9db2b

Browse files
committed
Auto merge of #1538 - RalfJung:rustup, r=RalfJung
rustup: work around rustc optimizations becoming too smart
2 parents 5f1182d + 3ba1035 commit bb9db2b

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

ci.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ function run_tests {
2525
./miri test --locked
2626
if ! [ -n "${MIRI_TEST_TARGET+exists}" ]; then
2727
# Only for host architecture: tests with MIR optimizations
28-
# FIXME:only testing level 1 because of <https://github.com/rust-lang/rust/issues/73223>.
29-
MIRI_TEST_FLAGS="-Z mir-opt-level=1" ./miri test --locked
28+
# FIXME: only testing level 2 because of <https://github.com/rust-lang/rust/issues/76432>.
29+
MIRI_TEST_FLAGS="-Z mir-opt-level=2" ./miri test --locked
3030
fi
3131
# "miri test" has built the sysroot for us, now this should pass without
3232
# any interactive questions.

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d2454643e137bde519786ee9e650c455d7ad6f34
1+
e114d6228b948ce056de0bcdec2603c8e89d3727

tests/compile-fail/invalid_bool.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
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+
#![feature(test)]
45

56
fn main() {
67
let b = unsafe { std::mem::transmute::<u8, bool>(2) };
7-
let _x = b == 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
89
}

tests/compile-fail/unaligned_pointers/unaligned_ptr_zst.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// compile-flags: -Zmiri-disable-validation
33

44
fn main() {
5-
for _ in 0..10 { // Try many times as this might work by chance.
6-
let x = 2u8;
5+
for i in 0..10 { // Try many times as this might work by chance.
6+
let x = i as u8;
77
let x = &x as *const _ as *const [u32; 0];
88
// This must fail because alignment is violated. Test specifically for loading ZST.
99
let _x = unsafe { *x }; //~ERROR alignment 4 is required

tests/run-pass/float.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
#![feature(stmt_expr_attributes)]
1+
// compile-flags: -Zmir-opt-level=0
2+
// FIXME: Using opt-level 2 here makes the test take forever (https://github.com/rust-lang/rust/issues/76433).
3+
#![feature(stmt_expr_attributes, test)]
24
use std::fmt::Debug;
5+
use std::hint::black_box;
36

47
// Helper function to avoid promotion so that this tests "run-time" casts, not CTFE.
58
// Doesn't make a big difference when running this in Miri, but it means we can compare this
@@ -339,10 +342,6 @@ fn ops() {
339342
/// Tests taken from rustc test suite.
340343
///
341344
342-
// Poor-man's black-box
343-
#[inline(never)]
344-
fn black_box<T>(x: T) -> T { x }
345-
346345
macro_rules! test {
347346
($val:expr, $src_ty:ident -> $dest_ty:ident, $expected:expr) => (
348347
// black_box disables constant evaluation to test run-time conversions:

tests/run-pass/u128.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
fn b<T>(t: T) -> T { t }
1+
#![feature(test)]
2+
use std::hint::black_box as b;
23

34
fn main() {
45
let x: u128 = 0xFFFF_FFFF_FFFF_FFFF__FFFF_FFFF_FFFF_FFFF;

0 commit comments

Comments
 (0)