summary refs log tree commit diff
path: root/tests/ui/panic-handler
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-09-22 05:07:45 +0000
committerbors <bors@rust-lang.org>2023-09-22 05:07:45 +0000
commitaace2dfa37f4589b0071530d2ed7b352f6196704 (patch)
tree085e424b22822d32e05954baa744c3b27e9fa42f /tests/ui/panic-handler
parentb7573187180a6ad13ba557f85b7e19a51f8fdaf1 (diff)
parent9102816bc4deca950b66cce402ea45573acc8fa0 (diff)
downloadrust-aace2dfa37f4589b0071530d2ed7b352f6196704.tar.gz
rust-aace2dfa37f4589b0071530d2ed7b352f6196704.zip
Auto merge of #115910 - eduardosm:lang-fns-target-features, r=cjgillot
Prevent using `#[target_feature]` on lang item functions

Fixes https://github.com/rust-lang/rust/issues/109411 and also prevents from using `#[target_feature]` on other `fn` lang items to mitigate the concerns from https://github.com/rust-lang/rust/issues/109411#issuecomment-1477030273.
Diffstat (limited to 'tests/ui/panic-handler')
-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
2 files changed, 26 insertions, 0 deletions
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 00000000000..8ea0275d7e9
--- /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 00000000000..4210a4200ae
--- /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
+