about summary refs log tree commit diff
path: root/compiler/rustc_passes/src
diff options
context:
space:
mode:
authorFolkert de Vries <folkert@folkertdev.nl>2025-03-16 21:14:41 +0100
committerFolkert de Vries <folkert@folkertdev.nl>2025-03-16 22:07:43 +0100
commitc26142697c417010fe338dddd2b771af872d02ba (patch)
treeb1e7f7a8c1dbba5dbea72934b0494966278047a3 /compiler/rustc_passes/src
parent8b87fefd76665236a304d3c0998e1021710ce1b0 (diff)
downloadrust-c26142697c417010fe338dddd2b771af872d02ba.tar.gz
rust-c26142697c417010fe338dddd2b771af872d02ba.zip
add `naked_functions_target_feature` unstable feature
Diffstat (limited to 'compiler/rustc_passes/src')
-rw-r--r--compiler/rustc_passes/src/check_attr.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs
index ece5a53aaa9..7f624747a46 100644
--- a/compiler/rustc_passes/src/check_attr.rs
+++ b/compiler/rustc_passes/src/check_attr.rs
@@ -598,7 +598,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
             sym::repr,
             // code generation
             sym::cold,
-            sym::target_feature,
             // documentation
             sym::doc,
         ];
@@ -624,6 +623,21 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
                         _ => {}
                     }
 
+                    if other_attr.has_name(sym::target_feature) {
+                        if !self.tcx.features().naked_functions_target_feature() {
+                            feature_err(
+                                &self.tcx.sess,
+                                sym::naked_functions_target_feature,
+                                other_attr.span(),
+                                "`#[target_feature(/* ... */)]` is currently unstable on `#[naked]` functions",
+                            ).emit();
+
+                            return;
+                        } else {
+                            continue;
+                        }
+                    }
+
                     if !ALLOW_LIST.iter().any(|name| other_attr.has_name(*name)) {
                         self.dcx().emit_err(errors::NakedFunctionIncompatibleAttribute {
                             span: other_attr.span(),