@@ -4,7 +4,6 @@ use std::mem;
4
4
use std:: panic;
5
5
use std:: rc:: Rc ;
6
6
use std:: sync:: atomic:: { Ordering :: Relaxed , AtomicUsize } ;
7
- use std:: thread;
8
7
9
8
use rand:: { Rng , RngCore , thread_rng} ;
10
9
use rand:: seq:: SliceRandom ;
@@ -1406,11 +1405,10 @@ fn test_box_slice_clone() {
1406
1405
#[ test]
1407
1406
#[ allow( unused_must_use) ] // here, we care about the side effects of `.clone()`
1408
1407
#[ 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
1410
1409
fn test_box_slice_clone_panics ( ) {
1411
1410
use std:: sync:: Arc ;
1412
1411
use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
1413
- use std:: thread:: spawn;
1414
1412
1415
1413
struct Canary {
1416
1414
count : Arc < AtomicUsize > ,
@@ -1446,15 +1444,14 @@ fn test_box_slice_clone_panics() {
1446
1444
panics : true ,
1447
1445
} ;
1448
1446
1449
- spawn ( move || {
1447
+ std :: panic :: catch_unwind ( move || {
1450
1448
// When xs is dropped, +5.
1451
1449
let xs = vec ! [ canary. clone( ) , canary. clone( ) , canary. clone( ) , panic, canary]
1452
1450
. into_boxed_slice ( ) ;
1453
1451
1454
1452
// When panic is cloned, +3.
1455
1453
xs. clone ( ) ;
1456
1454
} )
1457
- . join ( )
1458
1455
. unwrap_err ( ) ;
1459
1456
1460
1457
// Total = 8
@@ -1566,7 +1563,7 @@ macro_rules! test {
1566
1563
}
1567
1564
1568
1565
let v = $input. to_owned( ) ;
1569
- let _ = thread :: spawn ( move || {
1566
+ let _ = std :: panic :: catch_unwind ( move || {
1570
1567
let mut v = v;
1571
1568
let mut panic_countdown = panic_countdown;
1572
1569
v. $func( |a, b| {
@@ -1577,7 +1574,7 @@ macro_rules! test {
1577
1574
panic_countdown -= 1 ;
1578
1575
a. cmp( b)
1579
1576
} )
1580
- } ) . join ( ) ;
1577
+ } ) ;
1581
1578
1582
1579
// Check that the number of things dropped is exactly
1583
1580
// what we expect (i.e., the contents of `v`).
@@ -1598,7 +1595,7 @@ thread_local!(static SILENCE_PANIC: Cell<bool> = Cell::new(false));
1598
1595
1599
1596
#[ test]
1600
1597
#[ 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
1602
1599
fn panic_safe ( ) {
1603
1600
let prev = panic:: take_hook ( ) ;
1604
1601
panic:: set_hook ( Box :: new ( move |info| {
0 commit comments