about summary refs log tree commit diff
path: root/tests/ui/panics
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-07-11 07:35:19 +0200
committerGitHub <noreply@github.com>2025-07-11 07:35:19 +0200
commit66799d0b83df8ef34df210ba454b59fce53fd1e9 (patch)
tree4d5703b8d224e0d654c41b81edd9eb7fed76be7d /tests/ui/panics
parent3d6eb225e26448b09fdec1ba7222f3e7174c6ac2 (diff)
parent259512e3b6a920b1e1eb6034fbc738e7b9815337 (diff)
downloadrust-66799d0b83df8ef34df210ba454b59fce53fd1e9.tar.gz
rust-66799d0b83df8ef34df210ba454b59fce53fd1e9.zip
Rollup merge of #143303 - Kivooeo:tf28, r=tgross35
`tests/ui`: A New Order [28/28] FINAL PART

> [!NOTE]
>
> Intermediate commits are intended to help review, but will be squashed prior to merge.

Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895.

r? ``@tgross35``
Diffstat (limited to 'tests/ui/panics')
-rw-r--r--tests/ui/panics/unwind-force-no-unwind-tables.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/ui/panics/unwind-force-no-unwind-tables.rs b/tests/ui/panics/unwind-force-no-unwind-tables.rs
new file mode 100644
index 00000000000..2226e4dd03e
--- /dev/null
+++ b/tests/ui/panics/unwind-force-no-unwind-tables.rs
@@ -0,0 +1,41 @@
+//! This test checks that Rust's unwinding mechanism correctly executes `Drop`
+//! implementations during stack unwinding, even when unwind tables (`uwtable`)
+//! are explicitly disabled via `-C force-unwind-tables=n`.
+
+//@ run-pass
+//@ needs-unwind
+//@ ignore-windows target requires uwtable
+//@ compile-flags: -C panic=unwind -C force-unwind-tables=n
+
+use std::panic::{self, AssertUnwindSafe};
+
+struct Increase<'a>(&'a mut u8);
+
+impl Drop for Increase<'_> {
+    fn drop(&mut self) {
+        *self.0 += 1;
+    }
+}
+
+#[inline(never)]
+fn unwind() {
+    panic!();
+}
+
+#[inline(never)]
+fn increase(count: &mut u8) {
+    let _increase = Increase(count);
+    unwind();
+}
+
+fn main() {
+    let mut count = 0;
+    assert!(
+        panic::catch_unwind(AssertUnwindSafe(
+            #[inline(never)]
+            || increase(&mut count)
+        ))
+        .is_err()
+    );
+    assert_eq!(count, 1);
+}