about summary refs log tree commit diff
path: root/tests/ui/panic-runtime
diff options
context:
space:
mode:
authorAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-05 09:13:28 +0100
committerAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-11 09:32:08 +0000
commitcf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch)
tree40a88d9a46aaf3e8870676eb2538378b75a263eb /tests/ui/panic-runtime
parentca855e6e42787ecd062d81d53336fe6788ef51a9 (diff)
downloadrust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.tar.gz
rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.zip
Move /src/test to /tests
Diffstat (limited to 'tests/ui/panic-runtime')
-rw-r--r--tests/ui/panic-runtime/abort-link-to-unwind-dylib.rs18
-rw-r--r--tests/ui/panic-runtime/abort-link-to-unwind-dylib.stderr4
-rw-r--r--tests/ui/panic-runtime/abort-link-to-unwinding-crates.rs40
-rw-r--r--tests/ui/panic-runtime/abort.rs43
-rw-r--r--tests/ui/panic-runtime/auxiliary/depends.rs8
-rw-r--r--tests/ui/panic-runtime/auxiliary/exit-success-if-unwind.rs16
-rw-r--r--tests/ui/panic-runtime/auxiliary/needs-abort.rs5
-rw-r--r--tests/ui/panic-runtime/auxiliary/needs-panic-runtime.rs6
-rw-r--r--tests/ui/panic-runtime/auxiliary/needs-unwind.rs13
-rw-r--r--tests/ui/panic-runtime/auxiliary/panic-runtime-abort.rs17
-rw-r--r--tests/ui/panic-runtime/auxiliary/panic-runtime-lang-items.rs15
-rw-r--r--tests/ui/panic-runtime/auxiliary/panic-runtime-unwind.rs17
-rw-r--r--tests/ui/panic-runtime/auxiliary/panic-runtime-unwind2.rs17
-rw-r--r--tests/ui/panic-runtime/auxiliary/wants-panic-runtime-abort.rs7
-rw-r--r--tests/ui/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs6
-rw-r--r--tests/ui/panic-runtime/bad-panic-flag1.rs4
-rw-r--r--tests/ui/panic-runtime/bad-panic-flag1.stderr2
-rw-r--r--tests/ui/panic-runtime/bad-panic-flag2.rs4
-rw-r--r--tests/ui/panic-runtime/bad-panic-flag2.stderr2
-rw-r--r--tests/ui/panic-runtime/incompatible-type.rs24
-rw-r--r--tests/ui/panic-runtime/link-to-abort.rs11
-rw-r--r--tests/ui/panic-runtime/link-to-unwind.rs10
-rw-r--r--tests/ui/panic-runtime/lto-abort.rs33
-rw-r--r--tests/ui/panic-runtime/lto-unwind.rs37
-rw-r--r--tests/ui/panic-runtime/need-abort-got-unwind.rs8
-rw-r--r--tests/ui/panic-runtime/need-abort-got-unwind.stderr4
-rw-r--r--tests/ui/panic-runtime/need-unwind-got-abort.rs9
-rw-r--r--tests/ui/panic-runtime/need-unwind-got-abort.stderr4
-rw-r--r--tests/ui/panic-runtime/needs-gate.rs7
-rw-r--r--tests/ui/panic-runtime/needs-gate.stderr21
-rw-r--r--tests/ui/panic-runtime/runtime-depend-on-needs-runtime.rs8
-rw-r--r--tests/ui/panic-runtime/transitive-link-a-bunch.rs15
-rw-r--r--tests/ui/panic-runtime/transitive-link-a-bunch.stderr8
-rw-r--r--tests/ui/panic-runtime/two-panic-runtimes.rs15
-rw-r--r--tests/ui/panic-runtime/unwind-interleaved.rs16
-rw-r--r--tests/ui/panic-runtime/unwind-rec.rs15
-rw-r--r--tests/ui/panic-runtime/unwind-rec2.rs23
-rw-r--r--tests/ui/panic-runtime/unwind-tables-target-required.rs10
-rw-r--r--tests/ui/panic-runtime/unwind-unique.rs12
-rw-r--r--tests/ui/panic-runtime/want-abort-got-unwind.rs9
-rw-r--r--tests/ui/panic-runtime/want-abort-got-unwind2.rs10
-rw-r--r--tests/ui/panic-runtime/want-unwind-got-abort.rs11
-rw-r--r--tests/ui/panic-runtime/want-unwind-got-abort.stderr4
-rw-r--r--tests/ui/panic-runtime/want-unwind-got-abort2.rs12
-rw-r--r--tests/ui/panic-runtime/want-unwind-got-abort2.stderr6
45 files changed, 586 insertions, 0 deletions
diff --git a/tests/ui/panic-runtime/abort-link-to-unwind-dylib.rs b/tests/ui/panic-runtime/abort-link-to-unwind-dylib.rs
new file mode 100644
index 00000000000..58a90a592c4
--- /dev/null
+++ b/tests/ui/panic-runtime/abort-link-to-unwind-dylib.rs
@@ -0,0 +1,18 @@
+// build-fail
+// compile-flags:-C panic=abort -C prefer-dynamic
+// needs-unwind
+// ignore-musl - no dylibs here
+// ignore-emscripten
+// ignore-sgx no dynamic lib support
+// error-pattern:`panic_unwind` is not compiled with this crate's panic strategy
+
+// This is a test where the local crate, compiled with `panic=abort`, links to
+// the standard library **dynamically** which is already linked against
+// `panic=unwind`. We should fail because the linked panic runtime does not
+// correspond with our `-C panic` option.
+//
+// Note that this test assumes that the dynamic version of the standard library
+// is linked to `panic_unwind`, which is currently the case.
+
+fn main() {
+}
diff --git a/tests/ui/panic-runtime/abort-link-to-unwind-dylib.stderr b/tests/ui/panic-runtime/abort-link-to-unwind-dylib.stderr
new file mode 100644
index 00000000000..704b81ae1ce
--- /dev/null
+++ b/tests/ui/panic-runtime/abort-link-to-unwind-dylib.stderr
@@ -0,0 +1,4 @@
+error: the linked panic runtime `panic_unwind` is not compiled with this crate's panic strategy `abort`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/panic-runtime/abort-link-to-unwinding-crates.rs b/tests/ui/panic-runtime/abort-link-to-unwinding-crates.rs
new file mode 100644
index 00000000000..566626513ef
--- /dev/null
+++ b/tests/ui/panic-runtime/abort-link-to-unwinding-crates.rs
@@ -0,0 +1,40 @@
+// run-pass
+#![allow(unused_variables)]
+// compile-flags:-C panic=abort
+// aux-build:exit-success-if-unwind.rs
+// no-prefer-dynamic
+// ignore-emscripten no processes
+// ignore-sgx no processes
+// ignore-macos
+
+extern crate exit_success_if_unwind;
+
+use std::process::Command;
+use std::env;
+
+fn main() {
+    let mut args = env::args_os();
+    let me = args.next().unwrap();
+
+    if let Some(s) = args.next() {
+        if &*s == "foo" {
+            exit_success_if_unwind::bar(do_panic);
+        }
+    }
+
+    let mut cmd = Command::new(env::args_os().next().unwrap());
+    cmd.arg("foo");
+
+
+    // ARMv6 hanges while printing the backtrace, see #41004
+    if cfg!(target_arch = "arm") && cfg!(target_env = "gnu") {
+        cmd.env("RUST_BACKTRACE", "0");
+    }
+
+    let s = cmd.status();
+    assert!(s.unwrap().code() != Some(0));
+}
+
+fn do_panic() {
+    panic!("try to catch me");
+}
diff --git a/tests/ui/panic-runtime/abort.rs b/tests/ui/panic-runtime/abort.rs
new file mode 100644
index 00000000000..dcc4061fde7
--- /dev/null
+++ b/tests/ui/panic-runtime/abort.rs
@@ -0,0 +1,43 @@
+// run-pass
+#![allow(unused_variables)]
+// compile-flags:-C panic=abort
+// no-prefer-dynamic
+// ignore-emscripten no processes
+// ignore-sgx no processes
+// ignore-macos
+
+use std::process::Command;
+use std::env;
+
+struct Bomb;
+
+impl Drop for Bomb {
+    fn drop(&mut self) {
+        std::process::exit(0);
+    }
+}
+
+fn main() {
+    let mut args = env::args_os();
+    let me = args.next().unwrap();
+
+    if let Some(s) = args.next() {
+        if &*s == "foo" {
+
+            let _bomb = Bomb;
+
+            panic!("try to catch me");
+        }
+    }
+
+    let mut cmd = Command::new(env::args_os().next().unwrap());
+    cmd.arg("foo");
+
+    // ARMv6 hanges while printing the backtrace, see #41004
+    if cfg!(target_arch = "arm") && cfg!(target_env = "gnu") {
+        cmd.env("RUST_BACKTRACE", "0");
+    }
+
+    let s = cmd.status();
+    assert!(s.unwrap().code() != Some(0));
+}
diff --git a/tests/ui/panic-runtime/auxiliary/depends.rs b/tests/ui/panic-runtime/auxiliary/depends.rs
new file mode 100644
index 00000000000..e9bc2f4893e
--- /dev/null
+++ b/tests/ui/panic-runtime/auxiliary/depends.rs
@@ -0,0 +1,8 @@
+// no-prefer-dynamic
+
+#![feature(panic_runtime)]
+#![crate_type = "rlib"]
+#![panic_runtime]
+#![no_std]
+
+extern crate needs_panic_runtime;
diff --git a/tests/ui/panic-runtime/auxiliary/exit-success-if-unwind.rs b/tests/ui/panic-runtime/auxiliary/exit-success-if-unwind.rs
new file mode 100644
index 00000000000..c0e05740542
--- /dev/null
+++ b/tests/ui/panic-runtime/auxiliary/exit-success-if-unwind.rs
@@ -0,0 +1,16 @@
+// no-prefer-dynamic
+
+#![crate_type = "rlib"]
+
+struct Bomb;
+
+impl Drop for Bomb {
+    fn drop(&mut self) {
+        std::process::exit(0);
+    }
+}
+
+pub fn bar(f: fn()) {
+    let _bomb = Bomb;
+    f();
+}
diff --git a/tests/ui/panic-runtime/auxiliary/needs-abort.rs b/tests/ui/panic-runtime/auxiliary/needs-abort.rs
new file mode 100644
index 00000000000..8fad49b5e9d
--- /dev/null
+++ b/tests/ui/panic-runtime/auxiliary/needs-abort.rs
@@ -0,0 +1,5 @@
+// compile-flags:-C panic=abort
+// no-prefer-dynamic
+
+#![crate_type = "rlib"]
+#![no_std]
diff --git a/tests/ui/panic-runtime/auxiliary/needs-panic-runtime.rs b/tests/ui/panic-runtime/auxiliary/needs-panic-runtime.rs
new file mode 100644
index 00000000000..3f030c169f6
--- /dev/null
+++ b/tests/ui/panic-runtime/auxiliary/needs-panic-runtime.rs
@@ -0,0 +1,6 @@
+// no-prefer-dynamic
+
+#![feature(needs_panic_runtime)]
+#![crate_type = "rlib"]
+#![needs_panic_runtime]
+#![no_std]
diff --git a/tests/ui/panic-runtime/auxiliary/needs-unwind.rs b/tests/ui/panic-runtime/auxiliary/needs-unwind.rs
new file mode 100644
index 00000000000..d555b531986
--- /dev/null
+++ b/tests/ui/panic-runtime/auxiliary/needs-unwind.rs
@@ -0,0 +1,13 @@
+// compile-flags:-C panic=unwind
+// no-prefer-dynamic
+
+#![crate_type = "rlib"]
+#![no_std]
+#![feature(c_unwind)]
+
+extern "C-unwind" fn foo() {}
+
+fn bar() {
+    let ptr: extern "C-unwind" fn() = foo;
+    ptr();
+}
diff --git a/tests/ui/panic-runtime/auxiliary/panic-runtime-abort.rs b/tests/ui/panic-runtime/auxiliary/panic-runtime-abort.rs
new file mode 100644
index 00000000000..c92015eeebc
--- /dev/null
+++ b/tests/ui/panic-runtime/auxiliary/panic-runtime-abort.rs
@@ -0,0 +1,17 @@
+// compile-flags:-C panic=abort
+// no-prefer-dynamic
+
+#![feature(panic_runtime)]
+#![crate_type = "rlib"]
+
+#![no_std]
+#![panic_runtime]
+
+#[no_mangle]
+pub extern "C" fn __rust_maybe_catch_panic() {}
+
+#[no_mangle]
+pub extern "C" fn __rust_start_panic() {}
+
+#[no_mangle]
+pub extern "C" fn rust_eh_personality() {}
diff --git a/tests/ui/panic-runtime/auxiliary/panic-runtime-lang-items.rs b/tests/ui/panic-runtime/auxiliary/panic-runtime-lang-items.rs
new file mode 100644
index 00000000000..b9ef2f32941
--- /dev/null
+++ b/tests/ui/panic-runtime/auxiliary/panic-runtime-lang-items.rs
@@ -0,0 +1,15 @@
+// no-prefer-dynamic
+
+#![crate_type = "rlib"]
+
+#![no_std]
+#![feature(lang_items)]
+
+use core::panic::PanicInfo;
+
+#[lang = "panic_impl"]
+fn panic_impl(info: &PanicInfo) -> ! { loop {} }
+#[lang = "eh_personality"]
+fn eh_personality() {}
+#[lang = "eh_catch_typeinfo"]
+static EH_CATCH_TYPEINFO: u8 = 0;
diff --git a/tests/ui/panic-runtime/auxiliary/panic-runtime-unwind.rs b/tests/ui/panic-runtime/auxiliary/panic-runtime-unwind.rs
new file mode 100644
index 00000000000..2f7aed9248a
--- /dev/null
+++ b/tests/ui/panic-runtime/auxiliary/panic-runtime-unwind.rs
@@ -0,0 +1,17 @@
+// compile-flags:-C panic=unwind
+// no-prefer-dynamic
+
+#![feature(panic_runtime)]
+#![crate_type = "rlib"]
+
+#![no_std]
+#![panic_runtime]
+
+#[no_mangle]
+pub extern "C" fn __rust_maybe_catch_panic() {}
+
+#[no_mangle]
+pub extern "C" fn __rust_start_panic() {}
+
+#[no_mangle]
+pub extern "C" fn rust_eh_personality() {}
diff --git a/tests/ui/panic-runtime/auxiliary/panic-runtime-unwind2.rs b/tests/ui/panic-runtime/auxiliary/panic-runtime-unwind2.rs
new file mode 100644
index 00000000000..2f7aed9248a
--- /dev/null
+++ b/tests/ui/panic-runtime/auxiliary/panic-runtime-unwind2.rs
@@ -0,0 +1,17 @@
+// compile-flags:-C panic=unwind
+// no-prefer-dynamic
+
+#![feature(panic_runtime)]
+#![crate_type = "rlib"]
+
+#![no_std]
+#![panic_runtime]
+
+#[no_mangle]
+pub extern "C" fn __rust_maybe_catch_panic() {}
+
+#[no_mangle]
+pub extern "C" fn __rust_start_panic() {}
+
+#[no_mangle]
+pub extern "C" fn rust_eh_personality() {}
diff --git a/tests/ui/panic-runtime/auxiliary/wants-panic-runtime-abort.rs b/tests/ui/panic-runtime/auxiliary/wants-panic-runtime-abort.rs
new file mode 100644
index 00000000000..3c0d2d6588e
--- /dev/null
+++ b/tests/ui/panic-runtime/auxiliary/wants-panic-runtime-abort.rs
@@ -0,0 +1,7 @@
+// compile-flags:-C panic=abort
+// no-prefer-dynamic
+
+#![crate_type = "rlib"]
+#![no_std]
+
+extern crate panic_runtime_abort;
diff --git a/tests/ui/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs b/tests/ui/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs
new file mode 100644
index 00000000000..d5f0102196f
--- /dev/null
+++ b/tests/ui/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs
@@ -0,0 +1,6 @@
+// no-prefer-dynamic
+
+#![crate_type = "rlib"]
+#![no_std]
+
+extern crate panic_runtime_unwind;
diff --git a/tests/ui/panic-runtime/bad-panic-flag1.rs b/tests/ui/panic-runtime/bad-panic-flag1.rs
new file mode 100644
index 00000000000..1ac6a3423ff
--- /dev/null
+++ b/tests/ui/panic-runtime/bad-panic-flag1.rs
@@ -0,0 +1,4 @@
+// compile-flags:-C panic=foo
+// error-pattern:either `unwind` or `abort` was expected
+
+fn main() {}
diff --git a/tests/ui/panic-runtime/bad-panic-flag1.stderr b/tests/ui/panic-runtime/bad-panic-flag1.stderr
new file mode 100644
index 00000000000..013373c6f93
--- /dev/null
+++ b/tests/ui/panic-runtime/bad-panic-flag1.stderr
@@ -0,0 +1,2 @@
+error: incorrect value `foo` for codegen option `panic` - either `unwind` or `abort` was expected
+
diff --git a/tests/ui/panic-runtime/bad-panic-flag2.rs b/tests/ui/panic-runtime/bad-panic-flag2.rs
new file mode 100644
index 00000000000..c79701c83f3
--- /dev/null
+++ b/tests/ui/panic-runtime/bad-panic-flag2.rs
@@ -0,0 +1,4 @@
+// compile-flags:-C panic
+// error-pattern:requires either `unwind` or `abort`
+
+fn main() {}
diff --git a/tests/ui/panic-runtime/bad-panic-flag2.stderr b/tests/ui/panic-runtime/bad-panic-flag2.stderr
new file mode 100644
index 00000000000..6ab94ea704d
--- /dev/null
+++ b/tests/ui/panic-runtime/bad-panic-flag2.stderr
@@ -0,0 +1,2 @@
+error: codegen option `panic` requires either `unwind` or `abort` (C panic=<value>)
+
diff --git a/tests/ui/panic-runtime/incompatible-type.rs b/tests/ui/panic-runtime/incompatible-type.rs
new file mode 100644
index 00000000000..026364a2058
--- /dev/null
+++ b/tests/ui/panic-runtime/incompatible-type.rs
@@ -0,0 +1,24 @@
+// Check that rust_eh_personality can have a different type signature than the
+// one hardcoded in the compiler.  Regression test for #70117. Used to fail with:
+//
+// Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
+//
+// build-pass
+// compile-flags: --crate-type=lib -Ccodegen-units=1
+#![no_std]
+#![panic_runtime]
+#![feature(panic_runtime)]
+#![feature(rustc_attrs)]
+
+pub struct DropMe;
+
+impl Drop for DropMe {
+    fn drop(&mut self) {}
+}
+
+pub fn test(_: DropMe) {
+    unreachable!();
+}
+
+#[rustc_std_internal_symbol]
+pub unsafe extern "C" fn rust_eh_personality() {}
diff --git a/tests/ui/panic-runtime/link-to-abort.rs b/tests/ui/panic-runtime/link-to-abort.rs
new file mode 100644
index 00000000000..422206c574d
--- /dev/null
+++ b/tests/ui/panic-runtime/link-to-abort.rs
@@ -0,0 +1,11 @@
+// run-pass
+
+// compile-flags:-C panic=abort
+// no-prefer-dynamic
+// ignore-macos
+
+#![feature(panic_abort)]
+
+extern crate panic_abort;
+
+fn main() {}
diff --git a/tests/ui/panic-runtime/link-to-unwind.rs b/tests/ui/panic-runtime/link-to-unwind.rs
new file mode 100644
index 00000000000..59036ca99bd
--- /dev/null
+++ b/tests/ui/panic-runtime/link-to-unwind.rs
@@ -0,0 +1,10 @@
+// run-pass
+
+// no-prefer-dynamic
+
+#![feature(panic_unwind)]
+
+extern crate panic_unwind;
+
+fn main() {
+}
diff --git a/tests/ui/panic-runtime/lto-abort.rs b/tests/ui/panic-runtime/lto-abort.rs
new file mode 100644
index 00000000000..5cc4c013235
--- /dev/null
+++ b/tests/ui/panic-runtime/lto-abort.rs
@@ -0,0 +1,33 @@
+// run-pass
+#![allow(unused_variables)]
+// compile-flags:-C lto -C panic=abort
+// no-prefer-dynamic
+// ignore-emscripten no processes
+// ignore-sgx no processes
+
+use std::process::Command;
+use std::env;
+
+struct Bomb;
+
+impl Drop for Bomb {
+    fn drop(&mut self) {
+        std::process::exit(0);
+    }
+}
+
+fn main() {
+    let mut args = env::args_os();
+    let me = args.next().unwrap();
+
+    if let Some(s) = args.next() {
+        if &*s == "foo" {
+
+            let _bomb = Bomb;
+
+            panic!("try to catch me");
+        }
+    }
+    let s = Command::new(env::args_os().next().unwrap()).arg("foo").status();
+    assert!(s.unwrap().code() != Some(0));
+}
diff --git a/tests/ui/panic-runtime/lto-unwind.rs b/tests/ui/panic-runtime/lto-unwind.rs
new file mode 100644
index 00000000000..24048ebe008
--- /dev/null
+++ b/tests/ui/panic-runtime/lto-unwind.rs
@@ -0,0 +1,37 @@
+// run-pass
+#![allow(unused_variables)]
+
+// compile-flags:-C lto -C panic=unwind
+// needs-unwind
+// no-prefer-dynamic
+// ignore-emscripten no processes
+// ignore-sgx no processes
+
+use std::process::Command;
+use std::env;
+
+struct Bomb;
+
+impl Drop for Bomb {
+    fn drop(&mut self) {
+        println!("hurray you ran me");
+    }
+}
+
+fn main() {
+    let mut args = env::args_os();
+    let me = args.next().unwrap();
+
+    if let Some(s) = args.next() {
+        if &*s == "foo" {
+
+            let _bomb = Bomb;
+
+            panic!("try to catch me");
+        }
+    }
+    let s = Command::new(env::args_os().next().unwrap()).arg("foo").output();
+    let s = s.unwrap();
+    assert!(!s.status.success());
+    assert!(String::from_utf8_lossy(&s.stdout).contains("hurray you ran me"));
+}
diff --git a/tests/ui/panic-runtime/need-abort-got-unwind.rs b/tests/ui/panic-runtime/need-abort-got-unwind.rs
new file mode 100644
index 00000000000..e92400931d2
--- /dev/null
+++ b/tests/ui/panic-runtime/need-abort-got-unwind.rs
@@ -0,0 +1,8 @@
+// build-fail
+// needs-unwind
+// error-pattern:is incompatible with this crate's strategy of `unwind`
+// aux-build:needs-abort.rs
+
+extern crate needs_abort;
+
+fn main() {}
diff --git a/tests/ui/panic-runtime/need-abort-got-unwind.stderr b/tests/ui/panic-runtime/need-abort-got-unwind.stderr
new file mode 100644
index 00000000000..d29c7875fd0
--- /dev/null
+++ b/tests/ui/panic-runtime/need-abort-got-unwind.stderr
@@ -0,0 +1,4 @@
+error: the crate `needs_abort` requires panic strategy `abort` which is incompatible with this crate's strategy of `unwind`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/panic-runtime/need-unwind-got-abort.rs b/tests/ui/panic-runtime/need-unwind-got-abort.rs
new file mode 100644
index 00000000000..6752ecf90d2
--- /dev/null
+++ b/tests/ui/panic-runtime/need-unwind-got-abort.rs
@@ -0,0 +1,9 @@
+// build-fail
+// error-pattern:is incompatible with this crate's strategy of `abort`
+// aux-build:needs-unwind.rs
+// compile-flags:-C panic=abort
+// no-prefer-dynamic
+
+extern crate needs_unwind;
+
+fn main() {}
diff --git a/tests/ui/panic-runtime/need-unwind-got-abort.stderr b/tests/ui/panic-runtime/need-unwind-got-abort.stderr
new file mode 100644
index 00000000000..4c71df3ebc1
--- /dev/null
+++ b/tests/ui/panic-runtime/need-unwind-got-abort.stderr
@@ -0,0 +1,4 @@
+error: the crate `needs_unwind` requires panic strategy `unwind` which is incompatible with this crate's strategy of `abort`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/panic-runtime/needs-gate.rs b/tests/ui/panic-runtime/needs-gate.rs
new file mode 100644
index 00000000000..9e143adfeb2
--- /dev/null
+++ b/tests/ui/panic-runtime/needs-gate.rs
@@ -0,0 +1,7 @@
+// gate-test-needs_panic_runtime
+// gate-test-panic_runtime
+
+#![panic_runtime] //~ ERROR: is an experimental feature
+#![needs_panic_runtime] //~ ERROR: is an experimental feature
+
+fn main() {}
diff --git a/tests/ui/panic-runtime/needs-gate.stderr b/tests/ui/panic-runtime/needs-gate.stderr
new file mode 100644
index 00000000000..e067ccaebcf
--- /dev/null
+++ b/tests/ui/panic-runtime/needs-gate.stderr
@@ -0,0 +1,21 @@
+error[E0658]: the `#[panic_runtime]` attribute is an experimental feature
+  --> $DIR/needs-gate.rs:4:1
+   |
+LL | #![panic_runtime]
+   | ^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #32837 <https://github.com/rust-lang/rust/issues/32837> for more information
+   = help: add `#![feature(panic_runtime)]` to the crate attributes to enable
+
+error[E0658]: the `#[needs_panic_runtime]` attribute is an experimental feature
+  --> $DIR/needs-gate.rs:5:1
+   |
+LL | #![needs_panic_runtime]
+   | ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #32837 <https://github.com/rust-lang/rust/issues/32837> for more information
+   = help: add `#![feature(needs_panic_runtime)]` to the crate attributes to enable
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/panic-runtime/runtime-depend-on-needs-runtime.rs b/tests/ui/panic-runtime/runtime-depend-on-needs-runtime.rs
new file mode 100644
index 00000000000..d57f1643e98
--- /dev/null
+++ b/tests/ui/panic-runtime/runtime-depend-on-needs-runtime.rs
@@ -0,0 +1,8 @@
+// dont-check-compiler-stderr
+// aux-build:needs-panic-runtime.rs
+// aux-build:depends.rs
+// error-pattern:cannot depend on a crate that needs a panic runtime
+
+extern crate depends;
+
+fn main() {}
diff --git a/tests/ui/panic-runtime/transitive-link-a-bunch.rs b/tests/ui/panic-runtime/transitive-link-a-bunch.rs
new file mode 100644
index 00000000000..0e74e300f00
--- /dev/null
+++ b/tests/ui/panic-runtime/transitive-link-a-bunch.rs
@@ -0,0 +1,15 @@
+// build-fail
+// needs-unwind
+// aux-build:panic-runtime-unwind.rs
+// aux-build:panic-runtime-abort.rs
+// aux-build:wants-panic-runtime-unwind.rs
+// aux-build:wants-panic-runtime-abort.rs
+// aux-build:panic-runtime-lang-items.rs
+// error-pattern: is not compiled with this crate's panic strategy `unwind`
+
+#![no_std]
+#![no_main]
+
+extern crate wants_panic_runtime_unwind;
+extern crate wants_panic_runtime_abort;
+extern crate panic_runtime_lang_items;
diff --git a/tests/ui/panic-runtime/transitive-link-a-bunch.stderr b/tests/ui/panic-runtime/transitive-link-a-bunch.stderr
new file mode 100644
index 00000000000..7f4a8ed290e
--- /dev/null
+++ b/tests/ui/panic-runtime/transitive-link-a-bunch.stderr
@@ -0,0 +1,8 @@
+error: cannot link together two panic runtimes: panic_runtime_unwind and panic_runtime_abort
+
+error: the linked panic runtime `panic_runtime_abort` is not compiled with this crate's panic strategy `unwind`
+
+error: the crate `wants_panic_runtime_abort` requires panic strategy `abort` which is incompatible with this crate's strategy of `unwind`
+
+error: aborting due to 3 previous errors
+
diff --git a/tests/ui/panic-runtime/two-panic-runtimes.rs b/tests/ui/panic-runtime/two-panic-runtimes.rs
new file mode 100644
index 00000000000..7ec658ebcf2
--- /dev/null
+++ b/tests/ui/panic-runtime/two-panic-runtimes.rs
@@ -0,0 +1,15 @@
+// build-fail
+// dont-check-compiler-stderr
+// error-pattern:cannot link together two panic runtimes: panic_runtime_unwind and panic_runtime_unwind2
+// aux-build:panic-runtime-unwind.rs
+// aux-build:panic-runtime-unwind2.rs
+// aux-build:panic-runtime-lang-items.rs
+
+#![no_std]
+#![no_main]
+
+extern crate panic_runtime_unwind;
+extern crate panic_runtime_unwind2;
+extern crate panic_runtime_lang_items;
+
+fn main() {}
diff --git a/tests/ui/panic-runtime/unwind-interleaved.rs b/tests/ui/panic-runtime/unwind-interleaved.rs
new file mode 100644
index 00000000000..a8b3f349309
--- /dev/null
+++ b/tests/ui/panic-runtime/unwind-interleaved.rs
@@ -0,0 +1,16 @@
+// run-fail
+// error-pattern:explicit panic
+// ignore-emscripten no processes
+
+fn a() {}
+
+fn b() {
+    panic!();
+}
+
+fn main() {
+    let _x = vec![0];
+    a();
+    let _y = vec![0];
+    b();
+}
diff --git a/tests/ui/panic-runtime/unwind-rec.rs b/tests/ui/panic-runtime/unwind-rec.rs
new file mode 100644
index 00000000000..a9b7ee8ec7d
--- /dev/null
+++ b/tests/ui/panic-runtime/unwind-rec.rs
@@ -0,0 +1,15 @@
+// run-fail
+// error-pattern:explicit panic
+// ignore-emscripten no processes
+
+fn build() -> Vec<isize> {
+    panic!();
+}
+
+struct Blk {
+    node: Vec<isize>,
+}
+
+fn main() {
+    let _blk = Blk { node: build() };
+}
diff --git a/tests/ui/panic-runtime/unwind-rec2.rs b/tests/ui/panic-runtime/unwind-rec2.rs
new file mode 100644
index 00000000000..a130f9e879f
--- /dev/null
+++ b/tests/ui/panic-runtime/unwind-rec2.rs
@@ -0,0 +1,23 @@
+// run-fail
+// error-pattern:explicit panic
+// ignore-emscripten no processes
+
+fn build1() -> Vec<isize> {
+    vec![0, 0, 0, 0, 0, 0, 0]
+}
+
+fn build2() -> Vec<isize> {
+    panic!();
+}
+
+struct Blk {
+    node: Vec<isize>,
+    span: Vec<isize>,
+}
+
+fn main() {
+    let _blk = Blk {
+        node: build1(),
+        span: build2(),
+    };
+}
diff --git a/tests/ui/panic-runtime/unwind-tables-target-required.rs b/tests/ui/panic-runtime/unwind-tables-target-required.rs
new file mode 100644
index 00000000000..3abb52b675a
--- /dev/null
+++ b/tests/ui/panic-runtime/unwind-tables-target-required.rs
@@ -0,0 +1,10 @@
+// Tests that the compiler errors if the user tries to turn off unwind tables
+// when they are required.
+//
+// only-x86_64-windows-msvc
+// compile-flags: -C force-unwind-tables=no
+//
+// error-pattern: target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`.
+
+pub fn main() {
+}
diff --git a/tests/ui/panic-runtime/unwind-unique.rs b/tests/ui/panic-runtime/unwind-unique.rs
new file mode 100644
index 00000000000..d66e39110ea
--- /dev/null
+++ b/tests/ui/panic-runtime/unwind-unique.rs
@@ -0,0 +1,12 @@
+// run-fail
+// error-pattern:explicit panic
+// ignore-emscripten no processes
+
+fn failfn() {
+    panic!();
+}
+
+fn main() {
+    Box::new(0);
+    failfn();
+}
diff --git a/tests/ui/panic-runtime/want-abort-got-unwind.rs b/tests/ui/panic-runtime/want-abort-got-unwind.rs
new file mode 100644
index 00000000000..e33c3bcc3f0
--- /dev/null
+++ b/tests/ui/panic-runtime/want-abort-got-unwind.rs
@@ -0,0 +1,9 @@
+// build-fail
+// dont-check-compiler-stderr
+// error-pattern:is not compiled with this crate's panic strategy `abort`
+// aux-build:panic-runtime-unwind.rs
+// compile-flags:-C panic=abort
+
+extern crate panic_runtime_unwind;
+
+fn main() {}
diff --git a/tests/ui/panic-runtime/want-abort-got-unwind2.rs b/tests/ui/panic-runtime/want-abort-got-unwind2.rs
new file mode 100644
index 00000000000..438f1d85a28
--- /dev/null
+++ b/tests/ui/panic-runtime/want-abort-got-unwind2.rs
@@ -0,0 +1,10 @@
+// build-fail
+// dont-check-compiler-stderr
+// error-pattern:is not compiled with this crate's panic strategy `abort`
+// aux-build:panic-runtime-unwind.rs
+// aux-build:wants-panic-runtime-unwind.rs
+// compile-flags:-C panic=abort
+
+extern crate wants_panic_runtime_unwind;
+
+fn main() {}
diff --git a/tests/ui/panic-runtime/want-unwind-got-abort.rs b/tests/ui/panic-runtime/want-unwind-got-abort.rs
new file mode 100644
index 00000000000..b6174dc4efe
--- /dev/null
+++ b/tests/ui/panic-runtime/want-unwind-got-abort.rs
@@ -0,0 +1,11 @@
+// build-fail
+// needs-unwind
+// error-pattern:is not compiled with this crate's panic strategy `unwind`
+// aux-build:panic-runtime-abort.rs
+// aux-build:panic-runtime-lang-items.rs
+
+#![no_std]
+#![no_main]
+
+extern crate panic_runtime_abort;
+extern crate panic_runtime_lang_items;
diff --git a/tests/ui/panic-runtime/want-unwind-got-abort.stderr b/tests/ui/panic-runtime/want-unwind-got-abort.stderr
new file mode 100644
index 00000000000..d306ce6c5ea
--- /dev/null
+++ b/tests/ui/panic-runtime/want-unwind-got-abort.stderr
@@ -0,0 +1,4 @@
+error: the linked panic runtime `panic_runtime_abort` is not compiled with this crate's panic strategy `unwind`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/panic-runtime/want-unwind-got-abort2.rs b/tests/ui/panic-runtime/want-unwind-got-abort2.rs
new file mode 100644
index 00000000000..b54babbeffa
--- /dev/null
+++ b/tests/ui/panic-runtime/want-unwind-got-abort2.rs
@@ -0,0 +1,12 @@
+// build-fail
+// needs-unwind
+// error-pattern:is incompatible with this crate's strategy of `unwind`
+// aux-build:panic-runtime-abort.rs
+// aux-build:wants-panic-runtime-abort.rs
+// aux-build:panic-runtime-lang-items.rs
+
+#![no_std]
+#![no_main]
+
+extern crate wants_panic_runtime_abort;
+extern crate panic_runtime_lang_items;
diff --git a/tests/ui/panic-runtime/want-unwind-got-abort2.stderr b/tests/ui/panic-runtime/want-unwind-got-abort2.stderr
new file mode 100644
index 00000000000..014437b7f1b
--- /dev/null
+++ b/tests/ui/panic-runtime/want-unwind-got-abort2.stderr
@@ -0,0 +1,6 @@
+error: the linked panic runtime `panic_runtime_abort` is not compiled with this crate's panic strategy `unwind`
+
+error: the crate `wants_panic_runtime_abort` requires panic strategy `abort` which is incompatible with this crate's strategy of `unwind`
+
+error: aborting due to 2 previous errors
+