@@ -249,10 +249,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
249
249
{
250
250
if tcx. sess . target . is_like_wasm || tcx. sess . opts . actually_rustdoc {
251
251
// The `#[target_feature]` attribute is allowed on
252
- // WebAssembly targets on all functions, including safe
253
- // ones. Other targets require that `#[target_feature]` is
254
- // only applied to unsafe functions (pending the
255
- // `target_feature_11` feature) because on most targets
252
+ // WebAssembly targets on all functions. Prior to stabilizing
253
+ // the `target_feature_11` feature, `#[target_feature]` was
254
+ // only permitted on safe functions because on most targets
256
255
// execution of instructions that are not supported is
257
256
// considered undefined behavior. For WebAssembly which is a
258
257
// 100% safe target at execution time it's not possible to
@@ -266,17 +265,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
266
265
// if a target is documenting some wasm-specific code then
267
266
// it's not spuriously denied.
268
267
//
269
- // This exception needs to be kept in sync with allowing
270
- // `#[target_feature]` on `main` and `start`.
271
- } else if !tcx. features ( ) . target_feature_11 ( ) {
272
- feature_err (
273
- & tcx. sess ,
274
- sym:: target_feature_11,
275
- attr. span ,
276
- "`#[target_feature(..)]` can only be applied to `unsafe` functions" ,
277
- )
278
- . with_span_label ( tcx. def_span ( did) , "not an `unsafe` function" )
279
- . emit ( ) ;
268
+ // Now that `#[target_feature]` is permitted on safe functions,
269
+ // this exception must still exist for allowing the attribute on
270
+ // `main`, `start`, and other functions that are not usually
271
+ // allowed.
280
272
} else {
281
273
check_target_feature_trait_unsafe ( tcx, did, attr. span ) ;
282
274
}
@@ -584,10 +576,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
584
576
// its parent function, which effectively inherits the features anyway. Boxing this closure
585
577
// would result in this closure being compiled without the inherited target features, but this
586
578
// is probably a poor usage of `#[inline(always)]` and easily avoided by not using the attribute.
587
- if tcx. features ( ) . target_feature_11 ( )
588
- && tcx. is_closure_like ( did. to_def_id ( ) )
589
- && codegen_fn_attrs. inline != InlineAttr :: Always
590
- {
579
+ if tcx. is_closure_like ( did. to_def_id ( ) ) && codegen_fn_attrs. inline != InlineAttr :: Always {
591
580
let owner_id = tcx. parent ( did. to_def_id ( ) ) ;
592
581
if tcx. def_kind ( owner_id) . has_codegen_attrs ( ) {
593
582
codegen_fn_attrs
0 commit comments