diff --git a/src/tools/miri/tests/pass/concurrency/simple.rs b/src/tools/miri/tests/pass/concurrency/simple.rs index ec549a998ba..46033eea35d 100644 --- a/src/tools/miri/tests/pass/concurrency/simple.rs +++ b/src/tools/miri/tests/pass/concurrency/simple.rs @@ -45,23 +45,6 @@ fn create_move_out() { assert_eq!(result.len(), 6); } -fn panic() { - let result = thread::spawn(|| panic!("Hello!")).join().unwrap_err(); - let msg = result.downcast_ref::<&'static str>().unwrap(); - assert_eq!(*msg, "Hello!"); -} - -fn panic_named() { - thread::Builder::new() - .name("childthread".to_string()) - .spawn(move || { - panic!("Hello, world!"); - }) - .unwrap() - .join() - .unwrap_err(); -} - // This is not a data race! fn shared_readonly() { use std::sync::Arc; @@ -89,6 +72,4 @@ fn main() { create_move_in(); create_move_out(); shared_readonly(); - panic(); - panic_named(); } diff --git a/src/tools/miri/tests/pass/concurrency/simple.stderr b/src/tools/miri/tests/pass/concurrency/simple.stderr deleted file mode 100644 index 33d6b6841ad..00000000000 --- a/src/tools/miri/tests/pass/concurrency/simple.stderr +++ /dev/null @@ -1,5 +0,0 @@ -thread '' panicked at $DIR/simple.rs:LL:CC: -Hello! -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'childthread' panicked at $DIR/simple.rs:LL:CC: -Hello, world! diff --git a/src/tools/miri/tests/pass/concurrency/thread_name.rs b/src/tools/miri/tests/pass/concurrency/thread_name.rs new file mode 100644 index 00000000000..6dd5f1f5c91 --- /dev/null +++ b/src/tools/miri/tests/pass/concurrency/thread_name.rs @@ -0,0 +1,21 @@ +use std::thread; + +fn main() { + // When we have not set the name... + thread::spawn(|| { + assert!(thread::current().name().is_none()); + }); + + // ... and when we have set it. + thread::Builder::new() + .name("childthread".to_string()) + .spawn(move || { + assert_eq!(thread::current().name().unwrap(), "childthread"); + }) + .unwrap() + .join() + .unwrap(); + + // Also check main thread name. + assert_eq!(thread::current().name().unwrap(), "main"); +} diff --git a/src/tools/miri/tests/pass/panic/thread_panic.rs b/src/tools/miri/tests/pass/panic/thread_panic.rs new file mode 100644 index 00000000000..9a3040b2c56 --- /dev/null +++ b/src/tools/miri/tests/pass/panic/thread_panic.rs @@ -0,0 +1,25 @@ +//! Panicking in other threads. + +use std::thread; + +fn panic() { + let result = thread::spawn(|| panic!("Hello!")).join().unwrap_err(); + let msg = result.downcast_ref::<&'static str>().unwrap(); + assert_eq!(*msg, "Hello!"); +} + +fn panic_named() { + thread::Builder::new() + .name("childthread".to_string()) + .spawn(move || { + panic!("Hello, world!"); + }) + .unwrap() + .join() + .unwrap_err(); +} + +fn main() { + panic(); + panic_named(); +} diff --git a/src/tools/miri/tests/pass/panic/thread_panic.stderr b/src/tools/miri/tests/pass/panic/thread_panic.stderr new file mode 100644 index 00000000000..badd409d13f --- /dev/null +++ b/src/tools/miri/tests/pass/panic/thread_panic.stderr @@ -0,0 +1,5 @@ +thread '' panicked at $DIR/thread_panic.rs:LL:CC: +Hello! +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +thread 'childthread' panicked at $DIR/thread_panic.rs:LL:CC: +Hello, world!