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.
188
+
The*`target_feature` [attribute]* may be applied to a function to enable code generation of that function for specific platform architecture features.
189
189
190
190
> [!EXAMPLE]
191
191
> ```rust
@@ -194,6 +194,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
214
+
215
+
It is not allowed on the following places:
216
+
217
+
- [the `main` function][crate.main]
218
+
- a [`panic_handler` function][panic.panic_handler]
219
+
- safe trait methods
220
+
- safe default functions in traits
221
+
222
+
> [!NOTE]
223
+
> `rustc` currently warns on some positions where it is ignored, but this may become an error in the future.
224
+
225
+
r[attributes.codegen.target_feature.duplicates]
226
+
If the `target_feature` attribute is specified multiple times on an item, then the union of all the specified features are enabled.
227
+
197
228
r[attributes.codegen.target_feature.arch]
198
229
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.
199
230
@@ -243,14 +274,6 @@ fn bar_sse2() {
243
274
r[attributes.codegen.target_feature.fn-traits]
244
275
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:
248
-
249
-
-[the `main` function][crate.main]
250
-
- a [`panic_handler` function][panic.panic_handler]
251
-
- safe trait methods
252
-
- safe default functions in traits
253
-
254
277
r[attributes.codegen.target_feature.inline]
255
278
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