summaryrefslogtreecommitdiffstats
path: root/tests/ui/panic-handler
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /tests/ui/panic-handler
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/panic-handler')
-rw-r--r--tests/ui/panic-handler/panic-handler-bad-signature-1.rs7
-rw-r--r--tests/ui/panic-handler/panic-handler-bad-signature-1.stderr18
-rw-r--r--tests/ui/panic-handler/panic-handler-bad-signature-2.rs5
-rw-r--r--tests/ui/panic-handler/panic-handler-bad-signature-2.stderr12
-rw-r--r--tests/ui/panic-handler/panic-handler-bad-signature-3.rs2
-rw-r--r--tests/ui/panic-handler/panic-handler-bad-signature-3.stderr8
-rw-r--r--tests/ui/panic-handler/panic-handler-bad-signature-5.rs13
-rw-r--r--tests/ui/panic-handler/panic-handler-bad-signature-5.stderr12
-rw-r--r--tests/ui/panic-handler/panic-handler-with-target-feature.rs15
-rw-r--r--tests/ui/panic-handler/panic-handler-with-target-feature.stderr11
10 files changed, 78 insertions, 25 deletions
diff --git a/tests/ui/panic-handler/panic-handler-bad-signature-1.rs b/tests/ui/panic-handler/panic-handler-bad-signature-1.rs
index 775961d3f..ae27db7a8 100644
--- a/tests/ui/panic-handler/panic-handler-bad-signature-1.rs
+++ b/tests/ui/panic-handler/panic-handler-bad-signature-1.rs
@@ -6,8 +6,5 @@
use core::panic::PanicInfo;
#[panic_handler]
-fn panic(
- info: PanicInfo, //~ ERROR argument should be `&PanicInfo`
-) -> () //~ ERROR return type should be `!`
-{
-}
+fn panic(info: PanicInfo) -> () {}
+//~^ `#[panic_handler]` function has wrong type [E0308]
diff --git a/tests/ui/panic-handler/panic-handler-bad-signature-1.stderr b/tests/ui/panic-handler/panic-handler-bad-signature-1.stderr
index 8b044f766..85555c439 100644
--- a/tests/ui/panic-handler/panic-handler-bad-signature-1.stderr
+++ b/tests/ui/panic-handler/panic-handler-bad-signature-1.stderr
@@ -1,14 +1,12 @@
-error: return type should be `!`
- --> $DIR/panic-handler-bad-signature-1.rs:11:6
+error[E0308]: `#[panic_handler]` function has wrong type
+ --> $DIR/panic-handler-bad-signature-1.rs:9:16
|
-LL | ) -> ()
- | ^^
-
-error: argument should be `&PanicInfo`
- --> $DIR/panic-handler-bad-signature-1.rs:10:11
+LL | fn panic(info: PanicInfo) -> () {}
+ | ^^^^^^^^^ expected `&PanicInfo<'_>`, found `PanicInfo<'_>`
|
-LL | info: PanicInfo,
- | ^^^^^^^^^
+ = note: expected signature `for<'a, 'b> fn(&'a PanicInfo<'b>) -> !`
+ found signature `for<'a> fn(PanicInfo<'a>)`
-error: aborting due to 2 previous errors
+error: aborting due to previous error
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/panic-handler/panic-handler-bad-signature-2.rs b/tests/ui/panic-handler/panic-handler-bad-signature-2.rs
index 727934000..3c3f1513f 100644
--- a/tests/ui/panic-handler/panic-handler-bad-signature-2.rs
+++ b/tests/ui/panic-handler/panic-handler-bad-signature-2.rs
@@ -6,9 +6,8 @@
use core::panic::PanicInfo;
#[panic_handler]
-fn panic(
- info: &'static PanicInfo, //~ ERROR argument should be `&PanicInfo`
-) -> !
+fn panic(info: &'static PanicInfo) -> !
+//~^ #[panic_handler]` function has wrong type [E0308]
{
loop {}
}
diff --git a/tests/ui/panic-handler/panic-handler-bad-signature-2.stderr b/tests/ui/panic-handler/panic-handler-bad-signature-2.stderr
index 5ab693420..84eba2a5a 100644
--- a/tests/ui/panic-handler/panic-handler-bad-signature-2.stderr
+++ b/tests/ui/panic-handler/panic-handler-bad-signature-2.stderr
@@ -1,8 +1,12 @@
-error: argument should be `&PanicInfo`
- --> $DIR/panic-handler-bad-signature-2.rs:10:11
+error[E0308]: `#[panic_handler]` function has wrong type
+ --> $DIR/panic-handler-bad-signature-2.rs:9:1
|
-LL | info: &'static PanicInfo,
- | ^^^^^^^^^^^^^^^^^^
+LL | fn panic(info: &'static PanicInfo) -> !
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
+ |
+ = note: expected signature `for<'a, 'b> fn(&'a PanicInfo<'b>) -> _`
+ found signature `for<'a> fn(&'static PanicInfo<'a>) -> _`
error: aborting due to previous error
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/panic-handler/panic-handler-bad-signature-3.rs b/tests/ui/panic-handler/panic-handler-bad-signature-3.rs
index ab9c9d7f4..9e17e32fb 100644
--- a/tests/ui/panic-handler/panic-handler-bad-signature-3.rs
+++ b/tests/ui/panic-handler/panic-handler-bad-signature-3.rs
@@ -6,6 +6,6 @@
use core::panic::PanicInfo;
#[panic_handler]
-fn panic() -> ! { //~ ERROR function should have one argument
+fn panic() -> ! { //~ #[panic_handler]` function has wrong type [E0308]
loop {}
}
diff --git a/tests/ui/panic-handler/panic-handler-bad-signature-3.stderr b/tests/ui/panic-handler/panic-handler-bad-signature-3.stderr
index 0a70181fd..cdf55ab65 100644
--- a/tests/ui/panic-handler/panic-handler-bad-signature-3.stderr
+++ b/tests/ui/panic-handler/panic-handler-bad-signature-3.stderr
@@ -1,8 +1,12 @@
-error: function should have one argument
+error[E0308]: `#[panic_handler]` function has wrong type
--> $DIR/panic-handler-bad-signature-3.rs:9:1
|
LL | fn panic() -> ! {
- | ^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^ incorrect number of function parameters
+ |
+ = note: expected signature `for<'a, 'b> fn(&'a PanicInfo<'b>) -> _`
+ found signature `fn() -> _`
error: aborting due to previous error
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/panic-handler/panic-handler-bad-signature-5.rs b/tests/ui/panic-handler/panic-handler-bad-signature-5.rs
new file mode 100644
index 000000000..97307d1b2
--- /dev/null
+++ b/tests/ui/panic-handler/panic-handler-bad-signature-5.rs
@@ -0,0 +1,13 @@
+// compile-flags:-C panic=abort
+
+#![no_std]
+#![no_main]
+
+use core::panic::PanicInfo;
+
+#[panic_handler]
+fn panic(info: &PanicInfo<'static>) -> !
+//~^ #[panic_handler]` function has wrong type [E0308]
+{
+ loop {}
+}
diff --git a/tests/ui/panic-handler/panic-handler-bad-signature-5.stderr b/tests/ui/panic-handler/panic-handler-bad-signature-5.stderr
new file mode 100644
index 000000000..20c175875
--- /dev/null
+++ b/tests/ui/panic-handler/panic-handler-bad-signature-5.stderr
@@ -0,0 +1,12 @@
+error[E0308]: `#[panic_handler]` function has wrong type
+ --> $DIR/panic-handler-bad-signature-5.rs:9:1
+ |
+LL | fn panic(info: &PanicInfo<'static>) -> !
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
+ |
+ = note: expected signature `for<'a, 'b> fn(&'a PanicInfo<'b>) -> _`
+ found signature `for<'a> fn(&'a PanicInfo<'static>) -> _`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/panic-handler/panic-handler-with-target-feature.rs b/tests/ui/panic-handler/panic-handler-with-target-feature.rs
new file mode 100644
index 000000000..8ea0275d7
--- /dev/null
+++ b/tests/ui/panic-handler/panic-handler-with-target-feature.rs
@@ -0,0 +1,15 @@
+// compile-flags:-C panic=abort
+// only-x86_64
+
+#![feature(target_feature_11)]
+#![no_std]
+#![no_main]
+
+use core::panic::PanicInfo;
+
+#[panic_handler]
+#[target_feature(enable = "avx2")]
+//~^ ERROR `panic_impl` language item function is not allowed to have `#[target_feature]`
+fn panic(info: &PanicInfo) -> ! {
+ unimplemented!();
+}
diff --git a/tests/ui/panic-handler/panic-handler-with-target-feature.stderr b/tests/ui/panic-handler/panic-handler-with-target-feature.stderr
new file mode 100644
index 000000000..4210a4200
--- /dev/null
+++ b/tests/ui/panic-handler/panic-handler-with-target-feature.stderr
@@ -0,0 +1,11 @@
+error: `panic_impl` language item function is not allowed to have `#[target_feature]`
+ --> $DIR/panic-handler-with-target-feature.rs:11:1
+ |
+LL | #[target_feature(enable = "avx2")]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | fn panic(info: &PanicInfo) -> ! {
+ | ------------------------------- `panic_impl` language item function is not allowed to have `#[target_feature]`
+
+error: aborting due to previous error
+