Skip to content

Commit 6ff5b3f

Browse files
committed
make sure we also trigger debug assertions in libstd
1 parent 39a78f0 commit 6ff5b3f

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ pub use crate::stacked_borrows::{
6262
/// Insert rustc arguments at the beginning of the argument list that Miri wants to be
6363
/// set per default, for maximal validation power.
6464
pub fn miri_default_args() -> &'static [&'static str] {
65-
&["-Zalways-encode-mir", "-Zmir-emit-retag", "-Zmir-opt-level=0", "--cfg=miri"]
65+
&["-Zalways-encode-mir", "-Zmir-emit-retag", "-Zmir-opt-level=0", "--cfg=miri", "-Cdebug-assertions=on"]
6666
}

tests/run-pass/panic/catch_panic.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// ignore-windows: Unwind panicking does not currently work on Windows
2+
// normalize-stderr-test "[^ ]*libcore/macros/mod.rs[0-9:]*" -> "$$LOC"
23
#![feature(never_type)]
34
#![allow(const_err)]
45
use std::panic::{catch_unwind, AssertUnwindSafe};
@@ -11,7 +12,6 @@ thread_local! {
1112
}
1213

1314
struct DropTester;
14-
1515
impl Drop for DropTester {
1616
fn drop(&mut self) {
1717
DROPPED.with(|c| {
@@ -64,6 +64,7 @@ fn main() {
6464
// Assertion and debug assertion
6565
test(|_old_val| { assert!(false); loop {} });
6666
test(|_old_val| { debug_assert!(false); loop {} });
67+
test(|_old_val| { unsafe { (1 as *const i32).read() }; loop {} }); // trigger debug-assertion in libstd
6768

6869
// Cleanup: reset to default hook.
6970
drop(std::panic::take_hook());

tests/run-pass/panic/catch_panic.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:65:23
2020
Caught panic message (&str): assertion failed: false
2121
thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:66:23
2222
Caught panic message (&str): assertion failed: false
23+
thread 'main' panicked at 'attempt to copy from unaligned or null pointer', $LOC
24+
Caught panic message (String): attempt to copy from unaligned or null pointer
2325
Success!

0 commit comments

Comments
 (0)