Skip to content

Commit d446e46

Browse files
committed
Auto merge of #3039 - RalfJung:catch_panic, r=RalfJung
tests/catch_panic: make output easier to interpret
2 parents 5b7bb23 + 4cdffa2 commit d446e46

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

tests/pass/panic/catch_panic.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// We test the `align_offset` panic below, make sure we test the interpreter impl and not the "real" one.
2-
//@compile-flags: -Zmiri-symbolic-alignment-check -Zmiri-permissive-provenance
2+
//@compile-flags: -Zmiri-symbolic-alignment-check
33
#![feature(never_type)]
44
#![allow(unconditional_panic, non_fmt_panics)]
55

@@ -48,14 +48,16 @@ fn main() {
4848
}));
4949

5050
// Std panics
51-
test(None, |_old_val| std::panic!("Hello from panic: std"));
52-
test(None, |old_val| std::panic::panic_any(format!("Hello from panic: {:?}", old_val)));
53-
test(None, |old_val| std::panic!("Hello from panic: {:?}", old_val));
51+
test(None, |_old_val| std::panic!("Hello from std::panic"));
52+
test(None, |old_val| std::panic!("Hello from std::panic: {:?}", old_val));
53+
test(None, |old_val| {
54+
std::panic::panic_any(format!("Hello from std::panic_any: {:?}", old_val))
55+
});
5456
test(None, |_old_val| std::panic::panic_any(1337));
5557

5658
// Core panics
57-
test(None, |_old_val| core::panic!("Hello from panic: core"));
58-
test(None, |old_val| core::panic!("Hello from panic: {:?}", old_val));
59+
test(None, |_old_val| core::panic!("Hello from core::panic"));
60+
test(None, |old_val| core::panic!("Hello from core::panic: {:?}", old_val));
5961

6062
// Built-in panics; also make sure the message is right.
6163
test(Some("index out of bounds: the len is 3 but the index is 4"), |_old_val| {
@@ -68,7 +70,7 @@ fn main() {
6870
});
6971

7072
test(Some("align_offset: align is not a power-of-two"), |_old_val| {
71-
let _ = (0usize as *const u8).align_offset(3);
73+
let _ = std::ptr::null::<u8>().align_offset(3);
7274
loop {}
7375
});
7476

tests/pass/panic/catch_panic.stderr

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
2-
Hello from panic: std
2+
Hello from std::panic
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4-
Caught panic message (&str): Hello from panic: std
4+
Caught panic message (&str): Hello from std::panic
55
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
6-
Hello from panic: 1
7-
Caught panic message (String): Hello from panic: 1
6+
Hello from std::panic: 1
7+
Caught panic message (String): Hello from std::panic: 1
88
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
9-
Hello from panic: 2
10-
Caught panic message (String): Hello from panic: 2
9+
Hello from std::panic_any: 2
10+
Caught panic message (String): Hello from std::panic_any: 2
1111
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
1212
Box<dyn Any>
1313
Failed to get caught panic message.
1414
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
15-
Hello from panic: core
16-
Caught panic message (&str): Hello from panic: core
15+
Hello from core::panic
16+
Caught panic message (&str): Hello from core::panic
1717
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
18-
Hello from panic: 5
19-
Caught panic message (String): Hello from panic: 5
18+
Hello from core::panic: 5
19+
Caught panic message (String): Hello from core::panic: 5
2020
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
2121
index out of bounds: the len is 3 but the index is 4
2222
Caught panic message (String): index out of bounds: the len is 3 but the index is 4

0 commit comments

Comments
 (0)