]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-29948.rs
Enable full revision in const generics ui tests
[rust.git] / src / test / ui / issues / issue-29948.rs
1 // run-pass
2 // needs-unwind
3 // ignore-wasm32-bare compiled with panic=abort by default
4
5 use std::panic;
6
7 impl<'a> panic::UnwindSafe for Foo<'a> {}
8 impl<'a> panic::RefUnwindSafe for Foo<'a> {}
9
10 struct Foo<'a>(&'a mut bool);
11
12 impl<'a> Drop for Foo<'a> {
13     fn drop(&mut self) {
14         *self.0 = true;
15     }
16 }
17
18 fn f<T: FnOnce()>(t: T) {
19     t()
20 }
21
22 fn main() {
23     let mut ran_drop = false;
24     {
25         let x = Foo(&mut ran_drop);
26         let x = move || { let _ = x; };
27         f(x);
28     }
29     assert!(ran_drop);
30
31     let mut ran_drop = false;
32     {
33         let x = Foo(&mut ran_drop);
34         let result = panic::catch_unwind(move || {
35             let x = move || { let _ = x; panic!() };
36             f(x);
37         });
38         assert!(result.is_err());
39     }
40     assert!(ran_drop);
41 }