You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The *`target_feature`[attribute]* may be applied to a function to enable code generation of that function for specific platform architecture features. It uses the [MetaListNameValueStr] syntax with a single key of `enable` whose value is a string of comma-separated feature names to enable.
96
+
The *`target_feature`[attribute]* may be applied to a function to enable code generation of that function for specific platform architecture features.
97
97
98
98
> [!EXAMPLE]
99
99
> ```rust
@@ -102,6 +102,37 @@ The *`target_feature` [attribute]* may be applied to a function to enable code g
The given string is a comma-separated list of feature names to enable. See [available features](#available-features) for the list of features that are available.
-[Trait definition functions][items.traits] with a body
122
+
123
+
It is not allowed on the following places:
124
+
125
+
-[the `main` function][crate.main]
126
+
- a [`panic_handler` function][panic.panic_handler]
127
+
- safe trait methods
128
+
- safe default functions in traits
129
+
130
+
> [!NOTE]
131
+
> `rustc` currently warns on some positions where it is ignored, but this may become an error in the future.
132
+
133
+
r[attributes.codegen.target_feature.duplicates]
134
+
If the `target_feature` attribute is specified multiple times on an item, then the union of all the specified features are enabled.
135
+
105
136
r[attributes.codegen.target_feature.arch]
106
137
Each [target architecture] has a set of features that may be enabled. It is an error to specify a feature for a target architecture that the crate is not being compiled for.
107
138
@@ -151,14 +182,6 @@ fn bar_sse2() {
151
182
r[attributes.codegen.target_feature.fn-traits]
152
183
A function with a `#[target_feature]` attribute *never* implements the `Fn` family of traits, although closures inheriting features from the enclosing function do.
The `#[target_feature]` attribute is not allowed on the following places:
156
-
157
-
-[the `main` function][crate.main]
158
-
- a [`panic_handler` function][panic.panic_handler]
159
-
- safe trait methods
160
-
- safe default functions in traits
161
-
162
185
r[attributes.codegen.target_feature.inline]
163
186
Functions marked with `target_feature` are not inlined into a context that does not support the given features. The `#[inline(always)]` attribute may not be used with a `target_feature` attribute.
0 commit comments