3 #![deny(disjoint_capture_migration)]
4 // ignore-wasm32-bare compiled with panic=abort by default
7 #![feature(never_type)]
11 fn foo_diverges() -> ! { panic!() }
13 fn assert_panics<F>(f: F) where F: FnOnce() {
14 let f = panic::AssertUnwindSafe(f);
15 let result = panic::catch_unwind(move || {
16 //~^ ERROR: `UnwindSafe`, `RefUnwindSafe` trait implementation
17 //~| HELP: add a dummy let to cause `f` to be fully captured
20 if let Ok(..) = result {
21 panic!("diverging function returned");
25 fn test_fn_ptr_panic<T>(mut t: T)
28 let as_fn = <T as Fn<()>>::call;
29 assert_panics(|| as_fn(&t, ()));
30 let as_fn_mut = <T as FnMut<()>>::call_mut;
31 assert_panics(|| as_fn_mut(&mut t, ()));
32 let as_fn_once = <T as FnOnce<()>>::call_once;
33 assert_panics(|| as_fn_once(t, ()));
37 test_fn_ptr_panic(foo_diverges);
38 test_fn_ptr_panic(foo_diverges as fn() -> !);