From 9102816bc4deca950b66cce402ea45573acc8fa0 Mon Sep 17 00:00:00 2001 From: Eduardo Sánchez Muñoz Date: Mon, 18 Sep 2023 20:11:01 +0200 Subject: Prevent using `#[target_feature]` on lang item functions --- .../ui/panic-handler/panic-handler-with-target-feature.rs | 15 +++++++++++++++ .../panic-handler-with-target-feature.stderr | 11 +++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/ui/panic-handler/panic-handler-with-target-feature.rs create mode 100644 tests/ui/panic-handler/panic-handler-with-target-feature.stderr (limited to 'tests/ui/panic-handler') 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 + -- cgit 1.4.1-3-g733a5