Skip to content

Commit 6064367

Browse files
committed
Auto merge of #1604 - RalfJung:std-debug-assert, r=oli-obk
disable debug assertions in the standard library Debug assertions in the standard library can be somewhat expensive to check, in particular the ones covering each and every `ptr::write/copy/copy_nonoverlapping`. Miri will find most of those problems anyway since they cause UB. There are other debug assertions, such as ensuring internal invariants are maintained, but given how slow Miri already is, I think it is better to skip those checks in Miri and instead figure out a better way for people to use a standard library with debug assertions enabled.
2 parents b7d0cec + 1044099 commit 6064367

File tree

3 files changed

+2
-3
lines changed

3 files changed

+2
-3
lines changed

cargo-miri/bin.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ path = "lib.rs"
353353
// to the sysroot either.
354354
command.env_remove("RUSTC_WRAPPER");
355355
command.env_remove("RUSTFLAGS");
356+
// Disable debug assertions in the standard library -- Miri is already slow enough.
357+
command.env("RUSTFLAGS", "-Cdebug-assertions=off");
356358
// Finally run it!
357359
if command.status().expect("failed to run xargo").success().not() {
358360
show_error(format!("failed to run xargo"));

tests/run-pass/panic/catch_panic.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ fn main() {
7878
// Assertion and debug assertion
7979
test(None, |_old_val| { assert!(false); loop {} });
8080
test(None, |_old_val| { debug_assert!(false); loop {} });
81-
test(None, |_old_val| { unsafe { std::char::from_u32_unchecked(0xFD10000); } loop {} }); // trigger debug-assertion in libstd
8281

8382
eprintln!("Success!"); // Make sure we get this in stderr
8483
}

tests/run-pass/panic/catch_panic.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,4 @@ thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:LL:29
2323
Caught panic message (&str): assertion failed: false
2424
thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:LL:29
2525
Caught panic message (&str): assertion failed: false
26-
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', $LOC
27-
Caught panic message (&str): called `Option::unwrap()` on a `None` value
2826
Success!

0 commit comments

Comments
 (0)