]> git.lizzy.rs Git - rust.git/blob - src/test/ui/unwind-no-uwtable.rs
Rollup merge of #104024 - noeddl:unused-must-use, r=compiler-errors
[rust.git] / src / test / ui / unwind-no-uwtable.rs
1 // run-pass
2 // needs-unwind
3 // ignore-windows target requires uwtable
4 // compile-flags: -C panic=unwind -C force-unwind-tables=n
5
6 use std::panic::{self, AssertUnwindSafe};
7
8 struct Increase<'a>(&'a mut u8);
9
10 impl Drop for Increase<'_> {
11     fn drop(&mut self) {
12         *self.0 += 1;
13     }
14 }
15
16 #[inline(never)]
17 fn unwind() {
18     panic!();
19 }
20
21 #[inline(never)]
22 fn increase(count: &mut u8) {
23     let _increase = Increase(count);
24     unwind();
25 }
26
27 fn main() {
28     let mut count = 0;
29     assert!(panic::catch_unwind(AssertUnwindSafe(
30         #[inline(never)]
31         || increase(&mut count)
32     )).is_err());
33     assert_eq!(count, 1);
34 }