about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-01-15 12:06:56 +0000
committerbors <bors@rust-lang.org>2025-01-15 12:06:56 +0000
commit341f60327fa5302732a4be366949c16f91870b6a (patch)
tree319c3df4a34ed17a8b34f3a69331aa8c63444045 /compiler/rustc_middle/src/middle/codegen_fn_attrs.rs
parent2776bdfe423c9fdfcd6313d678f0852ea26f1309 (diff)
parent767d4fe64e3644ffcd89b3265fdee6659d08786a (diff)
downloadrust-341f60327fa5302732a4be366949c16f91870b6a.tar.gz
rust-341f60327fa5302732a4be366949c16f91870b6a.zip
Auto merge of #134353 - oli-obk:safe-target-feature-unsafe-by-default, r=wesleywiser
Treat safe target_feature functions as unsafe by default [less invasive variant]

This unblocks
* #134090

As I stated in https://github.com/rust-lang/rust/pull/134090#issuecomment-2541332415 I think the previous impl was too easy to get wrong, as by default it treated safe target feature functions as safe and had to add additional checks for when they weren't. Now the logic is inverted. By default they are unsafe and you have to explicitly handle safe target feature functions.

This is the less (imo) invasive variant of #134317, as it doesn't require changing the Safety enum, so it only affects FnDefs and nothing else, as it should.
Diffstat (limited to 'compiler/rustc_middle/src/middle/codegen_fn_attrs.rs')
-rw-r--r--compiler/rustc_middle/src/middle/codegen_fn_attrs.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs b/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs
index 16d868300db..e05f42af6fd 100644
--- a/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs
+++ b/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs
@@ -30,6 +30,8 @@ pub struct CodegenFnAttrs {
     /// features (only enabled features are supported right now).
     /// Implied target features have already been applied.
     pub target_features: Vec<TargetFeature>,
+    /// Whether the function was declared safe, but has target features
+    pub safe_target_features: bool,
     /// The `#[linkage = "..."]` attribute on Rust-defined items and the value we found.
     pub linkage: Option<Linkage>,
     /// The `#[linkage = "..."]` attribute on foreign items and the value we found.
@@ -150,6 +152,7 @@ impl CodegenFnAttrs {
             link_name: None,
             link_ordinal: None,
             target_features: vec![],
+            safe_target_features: false,
             linkage: None,
             import_linkage: None,
             link_section: None,