From 0966799b63ed0ed2ebdcddd386d4645de6732601 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 28 Aug 2023 12:12:45 +0200 Subject: [PATCH] tests/catch_panic: make output easier to interpret --- .../miri/tests/pass/panic/catch_panic.rs | 16 ++++++++------- .../miri/tests/pass/panic/catch_panic.stderr | 20 +++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/tools/miri/tests/pass/panic/catch_panic.rs b/src/tools/miri/tests/pass/panic/catch_panic.rs index 1b00f7cea30..e4a7f8e3481 100644 --- a/src/tools/miri/tests/pass/panic/catch_panic.rs +++ b/src/tools/miri/tests/pass/panic/catch_panic.rs @@ -1,5 +1,5 @@ // We test the `align_offset` panic below, make sure we test the interpreter impl and not the "real" one. -//@compile-flags: -Zmiri-symbolic-alignment-check -Zmiri-permissive-provenance +//@compile-flags: -Zmiri-symbolic-alignment-check #![feature(never_type)] #![allow(unconditional_panic, non_fmt_panics)] @@ -48,14 +48,16 @@ fn main() { })); // Std panics - test(None, |_old_val| std::panic!("Hello from panic: std")); - test(None, |old_val| std::panic::panic_any(format!("Hello from panic: {:?}", old_val))); - test(None, |old_val| std::panic!("Hello from panic: {:?}", old_val)); + test(None, |_old_val| std::panic!("Hello from std::panic")); + test(None, |old_val| std::panic!("Hello from std::panic: {:?}", old_val)); + test(None, |old_val| { + std::panic::panic_any(format!("Hello from std::panic_any: {:?}", old_val)) + }); test(None, |_old_val| std::panic::panic_any(1337)); // Core panics - test(None, |_old_val| core::panic!("Hello from panic: core")); - test(None, |old_val| core::panic!("Hello from panic: {:?}", old_val)); + test(None, |_old_val| core::panic!("Hello from core::panic")); + test(None, |old_val| core::panic!("Hello from core::panic: {:?}", old_val)); // Built-in panics; also make sure the message is right. test(Some("index out of bounds: the len is 3 but the index is 4"), |_old_val| { @@ -68,7 +70,7 @@ fn main() { }); test(Some("align_offset: align is not a power-of-two"), |_old_val| { - let _ = (0usize as *const u8).align_offset(3); + let _ = std::ptr::null::().align_offset(3); loop {} }); diff --git a/src/tools/miri/tests/pass/panic/catch_panic.stderr b/src/tools/miri/tests/pass/panic/catch_panic.stderr index aa005590db3..cbcd626e39f 100644 --- a/src/tools/miri/tests/pass/panic/catch_panic.stderr +++ b/src/tools/miri/tests/pass/panic/catch_panic.stderr @@ -1,22 +1,22 @@ thread 'main' panicked at $DIR/catch_panic.rs:LL:CC: -Hello from panic: std +Hello from std::panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -Caught panic message (&str): Hello from panic: std +Caught panic message (&str): Hello from std::panic thread 'main' panicked at $DIR/catch_panic.rs:LL:CC: -Hello from panic: 1 -Caught panic message (String): Hello from panic: 1 +Hello from std::panic: 1 +Caught panic message (String): Hello from std::panic: 1 thread 'main' panicked at $DIR/catch_panic.rs:LL:CC: -Hello from panic: 2 -Caught panic message (String): Hello from panic: 2 +Hello from std::panic_any: 2 +Caught panic message (String): Hello from std::panic_any: 2 thread 'main' panicked at $DIR/catch_panic.rs:LL:CC: Box Failed to get caught panic message. thread 'main' panicked at $DIR/catch_panic.rs:LL:CC: -Hello from panic: core -Caught panic message (&str): Hello from panic: core +Hello from core::panic +Caught panic message (&str): Hello from core::panic thread 'main' panicked at $DIR/catch_panic.rs:LL:CC: -Hello from panic: 5 -Caught panic message (String): Hello from panic: 5 +Hello from core::panic: 5 +Caught panic message (String): Hello from core::panic: 5 thread 'main' panicked at $DIR/catch_panic.rs:LL:CC: index out of bounds: the len is 3 but the index is 4 Caught panic message (String): index out of bounds: the len is 3 but the index is 4