@@ -4,7 +4,6 @@ use std::mem;
44use std:: panic;
55use std:: rc:: Rc ;
66use std:: sync:: atomic:: { Ordering :: Relaxed , AtomicUsize } ;
7- use std:: thread;
87
98use rand:: { Rng , RngCore , thread_rng} ;
109use rand:: seq:: SliceRandom ;
@@ -1406,11 +1405,10 @@ fn test_box_slice_clone() {
14061405#[ test]
14071406#[ allow( unused_must_use) ] // here, we care about the side effects of `.clone()`
14081407#[ cfg_attr( target_os = "emscripten" , ignore) ]
1409- #[ cfg( not( miri) ) ] // Miri does not support threads
1408+ #[ cfg( not( miri) ) ] // Miri does not support catching panics
14101409fn test_box_slice_clone_panics ( ) {
14111410 use std:: sync:: Arc ;
14121411 use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
1413- use std:: thread:: spawn;
14141412
14151413 struct Canary {
14161414 count : Arc < AtomicUsize > ,
@@ -1446,15 +1444,14 @@ fn test_box_slice_clone_panics() {
14461444 panics : true ,
14471445 } ;
14481446
1449- spawn ( move || {
1447+ std :: panic :: catch_unwind ( move || {
14501448 // When xs is dropped, +5.
14511449 let xs = vec ! [ canary. clone( ) , canary. clone( ) , canary. clone( ) , panic, canary]
14521450 . into_boxed_slice ( ) ;
14531451
14541452 // When panic is cloned, +3.
14551453 xs. clone ( ) ;
14561454 } )
1457- . join ( )
14581455 . unwrap_err ( ) ;
14591456
14601457 // Total = 8
@@ -1566,7 +1563,7 @@ macro_rules! test {
15661563 }
15671564
15681565 let v = $input. to_owned( ) ;
1569- let _ = thread :: spawn ( move || {
1566+ let _ = std :: panic :: catch_unwind ( move || {
15701567 let mut v = v;
15711568 let mut panic_countdown = panic_countdown;
15721569 v. $func( |a, b| {
@@ -1577,7 +1574,7 @@ macro_rules! test {
15771574 panic_countdown -= 1 ;
15781575 a. cmp( b)
15791576 } )
1580- } ) . join ( ) ;
1577+ } ) ;
15811578
15821579 // Check that the number of things dropped is exactly
15831580 // what we expect (i.e., the contents of `v`).
@@ -1598,7 +1595,7 @@ thread_local!(static SILENCE_PANIC: Cell<bool> = Cell::new(false));
15981595
15991596#[ test]
16001597#[ cfg_attr( target_os = "emscripten" , ignore) ] // no threads
1601- #[ cfg( not( miri) ) ] // Miri does not support threads
1598+ #[ cfg( not( miri) ) ] // Miri does not support catching panics
16021599fn panic_safe ( ) {
16031600 let prev = panic:: take_hook ( ) ;
16041601 panic:: set_hook ( Box :: new ( move |info| {
0 commit comments