about summary refs log tree commit diff
path: root/src/test/ui/panic-handler
diff options
context:
space:
mode:
authorJorge Aparicio <jorge@japaric.io>2018-08-23 00:40:32 +0200
committerJorge Aparicio <jorge@japaric.io>2018-08-23 20:58:55 +0200
commita774c81f9855f75a1a86f71a851b373d2178d9e9 (patch)
treeec4d2488935d22b9a2b07b36e9c27296df120ee5 /src/test/ui/panic-handler
parente5284b0b57275cb18618ef1532ee7f07c32a1e18 (diff)
downloadrust-a774c81f9855f75a1a86f71a851b373d2178d9e9.tar.gz
rust-a774c81f9855f75a1a86f71a851b373d2178d9e9.zip
add #[panic_handler]; deprecate #[panic_implementation]
Diffstat (limited to 'src/test/ui/panic-handler')
-rw-r--r--src/test/ui/panic-handler/auxiliary/some-panic-impl.rs22
-rw-r--r--src/test/ui/panic-handler/panic-handler-bad-signature-1.rs24
-rw-r--r--src/test/ui/panic-handler/panic-handler-bad-signature-1.stderr14
-rw-r--r--src/test/ui/panic-handler/panic-handler-bad-signature-2.rs25
-rw-r--r--src/test/ui/panic-handler/panic-handler-bad-signature-2.stderr8
-rw-r--r--src/test/ui/panic-handler/panic-handler-bad-signature-3.rs22
-rw-r--r--src/test/ui/panic-handler/panic-handler-bad-signature-3.stderr10
-rw-r--r--src/test/ui/panic-handler/panic-handler-bad-signature-4.rs23
-rw-r--r--src/test/ui/panic-handler/panic-handler-bad-signature-4.stderr11
-rw-r--r--src/test/ui/panic-handler/panic-handler-duplicate.rs28
-rw-r--r--src/test/ui/panic-handler/panic-handler-duplicate.stderr19
-rw-r--r--src/test/ui/panic-handler/panic-handler-requires-panic-info.rs26
-rw-r--r--src/test/ui/panic-handler/panic-handler-requires-panic-info.stderr4
-rw-r--r--src/test/ui/panic-handler/panic-handler-std.rs22
-rw-r--r--src/test/ui/panic-handler/panic-handler-std.stderr13
15 files changed, 271 insertions, 0 deletions
diff --git a/src/test/ui/panic-handler/auxiliary/some-panic-impl.rs b/src/test/ui/panic-handler/auxiliary/some-panic-impl.rs
new file mode 100644
index 00000000000..e3b4fba176e
--- /dev/null
+++ b/src/test/ui/panic-handler/auxiliary/some-panic-impl.rs
@@ -0,0 +1,22 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// no-prefer-dynamic
+
+#![crate_type = "rlib"]
+#![feature(panic_handler)]
+#![no_std]
+
+use core::panic::PanicInfo;
+
+#[panic_handler]
+fn panic(info: &PanicInfo) -> ! {
+    loop {}
+}
diff --git a/src/test/ui/panic-handler/panic-handler-bad-signature-1.rs b/src/test/ui/panic-handler/panic-handler-bad-signature-1.rs
new file mode 100644
index 00000000000..cc7e337fc9e
--- /dev/null
+++ b/src/test/ui/panic-handler/panic-handler-bad-signature-1.rs
@@ -0,0 +1,24 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags:-C panic=abort
+
+#![feature(panic_handler)]
+#![no_std]
+#![no_main]
+
+use core::panic::PanicInfo;
+
+#[panic_handler]
+fn panic(
+    info: PanicInfo, //~ ERROR argument should be `&PanicInfo`
+) -> () //~ ERROR return type should be `!`
+{
+}
diff --git a/src/test/ui/panic-handler/panic-handler-bad-signature-1.stderr b/src/test/ui/panic-handler/panic-handler-bad-signature-1.stderr
new file mode 100644
index 00000000000..5771f4277b4
--- /dev/null
+++ b/src/test/ui/panic-handler/panic-handler-bad-signature-1.stderr
@@ -0,0 +1,14 @@
+error: return type should be `!`
+  --> $DIR/panic-handler-bad-signature-1.rs:22:6
+   |
+LL | ) -> () //~ ERROR return type should be `!`
+   |      ^^
+
+error: argument should be `&PanicInfo`
+  --> $DIR/panic-handler-bad-signature-1.rs:21:11
+   |
+LL |     info: PanicInfo, //~ ERROR argument should be `&PanicInfo`
+   |           ^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/panic-handler/panic-handler-bad-signature-2.rs b/src/test/ui/panic-handler/panic-handler-bad-signature-2.rs
new file mode 100644
index 00000000000..ec698903c84
--- /dev/null
+++ b/src/test/ui/panic-handler/panic-handler-bad-signature-2.rs
@@ -0,0 +1,25 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags:-C panic=abort
+
+#![feature(panic_handler)]
+#![no_std]
+#![no_main]
+
+use core::panic::PanicInfo;
+
+#[panic_handler]
+fn panic(
+    info: &'static PanicInfo, //~ ERROR argument should be `&PanicInfo`
+) -> !
+{
+    loop {}
+}
diff --git a/src/test/ui/panic-handler/panic-handler-bad-signature-2.stderr b/src/test/ui/panic-handler/panic-handler-bad-signature-2.stderr
new file mode 100644
index 00000000000..4823f8a2781
--- /dev/null
+++ b/src/test/ui/panic-handler/panic-handler-bad-signature-2.stderr
@@ -0,0 +1,8 @@
+error: argument should be `&PanicInfo`
+  --> $DIR/panic-handler-bad-signature-2.rs:21:11
+   |
+LL |     info: &'static PanicInfo, //~ ERROR argument should be `&PanicInfo`
+   |           ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/panic-handler/panic-handler-bad-signature-3.rs b/src/test/ui/panic-handler/panic-handler-bad-signature-3.rs
new file mode 100644
index 00000000000..585716c7c75
--- /dev/null
+++ b/src/test/ui/panic-handler/panic-handler-bad-signature-3.rs
@@ -0,0 +1,22 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags:-C panic=abort
+
+#![feature(panic_handler)]
+#![no_std]
+#![no_main]
+
+use core::panic::PanicInfo;
+
+#[panic_handler]
+fn panic() -> ! { //~ ERROR function should have one argument
+    loop {}
+}
diff --git a/src/test/ui/panic-handler/panic-handler-bad-signature-3.stderr b/src/test/ui/panic-handler/panic-handler-bad-signature-3.stderr
new file mode 100644
index 00000000000..0eb0d4e1000
--- /dev/null
+++ b/src/test/ui/panic-handler/panic-handler-bad-signature-3.stderr
@@ -0,0 +1,10 @@
+error: function should have one argument
+  --> $DIR/panic-handler-bad-signature-3.rs:20:1
+   |
+LL | / fn panic() -> ! { //~ ERROR function should have one argument
+LL | |     loop {}
+LL | | }
+   | |_^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/panic-handler/panic-handler-bad-signature-4.rs b/src/test/ui/panic-handler/panic-handler-bad-signature-4.rs
new file mode 100644
index 00000000000..9cda37f27b3
--- /dev/null
+++ b/src/test/ui/panic-handler/panic-handler-bad-signature-4.rs
@@ -0,0 +1,23 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags:-C panic=abort
+
+#![feature(panic_handler)]
+#![no_std]
+#![no_main]
+
+use core::panic::PanicInfo;
+
+#[panic_handler]
+fn panic<T>(pi: &PanicInfo) -> ! {
+    //~^ ERROR should have no type parameters
+    loop {}
+}
diff --git a/src/test/ui/panic-handler/panic-handler-bad-signature-4.stderr b/src/test/ui/panic-handler/panic-handler-bad-signature-4.stderr
new file mode 100644
index 00000000000..a61b9b3743c
--- /dev/null
+++ b/src/test/ui/panic-handler/panic-handler-bad-signature-4.stderr
@@ -0,0 +1,11 @@
+error: should have no type parameters
+  --> $DIR/panic-handler-bad-signature-4.rs:20:1
+   |
+LL | / fn panic<T>(pi: &PanicInfo) -> ! {
+LL | |     //~^ ERROR should have no type parameters
+LL | |     loop {}
+LL | | }
+   | |_^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/panic-handler/panic-handler-duplicate.rs b/src/test/ui/panic-handler/panic-handler-duplicate.rs
new file mode 100644
index 00000000000..7d7fe251869
--- /dev/null
+++ b/src/test/ui/panic-handler/panic-handler-duplicate.rs
@@ -0,0 +1,28 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags:-C panic=abort
+
+#![feature(lang_items)]
+#![feature(panic_handler)]
+#![no_std]
+#![no_main]
+
+use core::panic::PanicInfo;
+
+#[panic_handler]
+fn panic(info: &PanicInfo) -> ! {
+    loop {}
+}
+
+#[lang = "panic_impl"]
+fn panic2(info: &PanicInfo) -> ! { //~ ERROR duplicate lang item found: `panic_impl`.
+    loop {}
+}
diff --git a/src/test/ui/panic-handler/panic-handler-duplicate.stderr b/src/test/ui/panic-handler/panic-handler-duplicate.stderr
new file mode 100644
index 00000000000..d8afaa27e26
--- /dev/null
+++ b/src/test/ui/panic-handler/panic-handler-duplicate.stderr
@@ -0,0 +1,19 @@
+error[E0152]: duplicate lang item found: `panic_impl`.
+  --> $DIR/panic-handler-duplicate.rs:26:1
+   |
+LL | / fn panic2(info: &PanicInfo) -> ! { //~ ERROR duplicate lang item found: `panic_impl`.
+LL | |     loop {}
+LL | | }
+   | |_^
+   |
+note: first defined here.
+  --> $DIR/panic-handler-duplicate.rs:21:1
+   |
+LL | / fn panic(info: &PanicInfo) -> ! {
+LL | |     loop {}
+LL | | }
+   | |_^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0152`.
diff --git a/src/test/ui/panic-handler/panic-handler-requires-panic-info.rs b/src/test/ui/panic-handler/panic-handler-requires-panic-info.rs
new file mode 100644
index 00000000000..ec68a414f54
--- /dev/null
+++ b/src/test/ui/panic-handler/panic-handler-requires-panic-info.rs
@@ -0,0 +1,26 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags:-C panic=abort
+// error-pattern: language item required, but not found: `panic_info`
+
+#![feature(lang_items)]
+#![feature(no_core)]
+#![feature(panic_handler)]
+#![no_core]
+#![no_main]
+
+#[panic_handler]
+fn panic() -> ! {
+    loop {}
+}
+
+#[lang = "sized"]
+trait Sized {}
diff --git a/src/test/ui/panic-handler/panic-handler-requires-panic-info.stderr b/src/test/ui/panic-handler/panic-handler-requires-panic-info.stderr
new file mode 100644
index 00000000000..2bae12efbde
--- /dev/null
+++ b/src/test/ui/panic-handler/panic-handler-requires-panic-info.stderr
@@ -0,0 +1,4 @@
+error: language item required, but not found: `panic_info`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/panic-handler/panic-handler-std.rs b/src/test/ui/panic-handler/panic-handler-std.rs
new file mode 100644
index 00000000000..7cbe0a35bae
--- /dev/null
+++ b/src/test/ui/panic-handler/panic-handler-std.rs
@@ -0,0 +1,22 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// error-pattern: duplicate lang item found: `panic_impl`.
+
+#![feature(panic_handler)]
+
+use std::panic::PanicInfo;
+
+#[panic_handler]
+fn panic(info: PanicInfo) -> ! {
+    loop {}
+}
+
+fn main() {}
diff --git a/src/test/ui/panic-handler/panic-handler-std.stderr b/src/test/ui/panic-handler/panic-handler-std.stderr
new file mode 100644
index 00000000000..c34a993e2c5
--- /dev/null
+++ b/src/test/ui/panic-handler/panic-handler-std.stderr
@@ -0,0 +1,13 @@
+error[E0152]: duplicate lang item found: `panic_impl`.
+  --> $DIR/panic-handler-std.rs:18:1
+   |
+LL | / fn panic(info: PanicInfo) -> ! {
+LL | |     loop {}
+LL | | }
+   | |_^
+   |
+   = note: first defined in crate `std`.
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0152`.