Skip to content

Commit 2b591b8

Browse files
committed
test panics in threads
1 parent 994b13e commit 2b591b8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

tests/run-pass/concurrency/simple.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ fn create_move_out() {
4949
assert_eq!(result.len(), 6);
5050
}
5151

52+
fn panic() {
53+
let result = thread::spawn(|| {
54+
panic!("Hello!")
55+
})
56+
.join()
57+
.unwrap_err();
58+
let msg = result.downcast_ref::<&'static str>().unwrap();
59+
assert_eq!(*msg, "Hello!");
60+
}
61+
5262
fn main() {
5363
create_and_detach();
5464
create_and_join();
@@ -58,4 +68,5 @@ fn main() {
5868
create_nested_and_join();
5969
create_move_in();
6070
create_move_out();
71+
panic();
6172
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
warning: thread support is experimental. For example, Miri does not detect data races yet.
22

3+
thread '<unnamed>' panicked at 'Hello!', $DIR/simple.rs:54:9

0 commit comments

Comments
 (0)