about summary refs log tree commit diff
path: root/src/test/ui/panic-handler
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-12-29 23:20:46 +0000
committerbors <bors@rust-lang.org>2020-12-29 23:20:46 +0000
commitf3eead1c69d5ce9cb128a9068250581ad28103f0 (patch)
tree9803bb601004e2fcb03d00009320067e439535d4 /src/test/ui/panic-handler
parent158f8d034b15e65ba8dc0d066358dd0632bfcd6e (diff)
parent4d2d0bad4e51d0d14d21b4e21cdb61b55dd11349 (diff)
downloadrust-f3eead1c69d5ce9cb128a9068250581ad28103f0.tar.gz
rust-f3eead1c69d5ce9cb128a9068250581ad28103f0.zip
Auto merge of #80453 - petrochenkov:nocfail, r=Mark-Simulacrum
Remove `compile-fail` test suite

By moving all of its tests to `ui` test suite.
Now we have directives like `// dont-check-compiler-stderr` that allow to disable `.stderr` comparison for platform-dependent tests without introducing a whole new test suite.
Diffstat (limited to 'src/test/ui/panic-handler')
-rw-r--r--src/test/ui/panic-handler/auxiliary/weak-lang-items.rs22
-rw-r--r--src/test/ui/panic-handler/panic-handler-missing.rs9
-rw-r--r--src/test/ui/panic-handler/panic-handler-twice.rs19
-rw-r--r--src/test/ui/panic-handler/weak-lang-item.rs11
-rw-r--r--src/test/ui/panic-handler/weak-lang-item.stderr19
5 files changed, 80 insertions, 0 deletions
diff --git a/src/test/ui/panic-handler/auxiliary/weak-lang-items.rs b/src/test/ui/panic-handler/auxiliary/weak-lang-items.rs
new file mode 100644
index 00000000000..7a698cf76ae
--- /dev/null
+++ b/src/test/ui/panic-handler/auxiliary/weak-lang-items.rs
@@ -0,0 +1,22 @@
+// no-prefer-dynamic
+
+// This aux-file will require the eh_personality function to be codegen'd, but
+// it hasn't been defined just yet. Make sure we don't explode.
+
+#![no_std]
+#![crate_type = "rlib"]
+
+struct A;
+
+impl core::ops::Drop for A {
+    fn drop(&mut self) {}
+}
+
+pub fn foo() {
+    let _a = A;
+    panic!("wut");
+}
+
+mod std {
+    pub use core::{option, fmt};
+}
diff --git a/src/test/ui/panic-handler/panic-handler-missing.rs b/src/test/ui/panic-handler/panic-handler-missing.rs
new file mode 100644
index 00000000000..6bb062ba657
--- /dev/null
+++ b/src/test/ui/panic-handler/panic-handler-missing.rs
@@ -0,0 +1,9 @@
+// dont-check-compiler-stderr
+// error-pattern: `#[panic_handler]` function required, but not found
+
+#![feature(lang_items)]
+#![no_main]
+#![no_std]
+
+#[lang = "eh_personality"]
+fn eh() {}
diff --git a/src/test/ui/panic-handler/panic-handler-twice.rs b/src/test/ui/panic-handler/panic-handler-twice.rs
new file mode 100644
index 00000000000..05bef66d849
--- /dev/null
+++ b/src/test/ui/panic-handler/panic-handler-twice.rs
@@ -0,0 +1,19 @@
+// dont-check-compiler-stderr
+// aux-build:some-panic-impl.rs
+
+#![feature(lang_items)]
+#![no_std]
+#![no_main]
+
+extern crate some_panic_impl;
+
+use core::panic::PanicInfo;
+
+#[panic_handler]
+fn panic(info: &PanicInfo) -> ! {
+    //~^ ERROR found duplicate lang item `panic_impl`
+    loop {}
+}
+
+#[lang = "eh_personality"]
+fn eh() {}
diff --git a/src/test/ui/panic-handler/weak-lang-item.rs b/src/test/ui/panic-handler/weak-lang-item.rs
new file mode 100644
index 00000000000..3fa3822831b
--- /dev/null
+++ b/src/test/ui/panic-handler/weak-lang-item.rs
@@ -0,0 +1,11 @@
+// aux-build:weak-lang-items.rs
+// error-pattern: `#[panic_handler]` function required, but not found
+// error-pattern: language item required, but not found: `eh_personality`
+// ignore-emscripten compiled with panic=abort, personality not required
+
+#![no_std]
+
+extern crate core;
+extern crate weak_lang_items;
+
+fn main() {}
diff --git a/src/test/ui/panic-handler/weak-lang-item.stderr b/src/test/ui/panic-handler/weak-lang-item.stderr
new file mode 100644
index 00000000000..b7c040c7a85
--- /dev/null
+++ b/src/test/ui/panic-handler/weak-lang-item.stderr
@@ -0,0 +1,19 @@
+error[E0259]: the name `core` is defined multiple times
+  --> $DIR/weak-lang-item.rs:8:1
+   |
+LL | extern crate core;
+   | ^^^^^^^^^^^^^^^^^^ `core` reimported here
+   |
+   = note: `core` must be defined only once in the type namespace of this module
+help: you can use `as` to change the binding name of the import
+   |
+LL | extern crate core as other_core;
+   |
+
+error: `#[panic_handler]` function required, but not found
+
+error: language item required, but not found: `eh_personality`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0259`.