@@ -278,10 +278,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
278
278
{
279
279
if tcx. sess . target . is_like_wasm || tcx. sess . opts . actually_rustdoc {
280
280
// The `#[target_feature]` attribute is allowed on
281
- // WebAssembly targets on all functions, including safe
282
- // ones. Other targets require that `#[target_feature]` is
283
- // only applied to unsafe functions (pending the
284
- // `target_feature_11` feature) because on most targets
281
+ // WebAssembly targets on all functions. Prior to stabilizing
282
+ // the `target_feature_11` feature, `#[target_feature]` was
283
+ // only permitted on safe functions because on most targets
285
284
// execution of instructions that are not supported is
286
285
// considered undefined behavior. For WebAssembly which is a
287
286
// 100% safe target at execution time it's not possible to
@@ -295,17 +294,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
295
294
// if a target is documenting some wasm-specific code then
296
295
// it's not spuriously denied.
297
296
//
298
- // This exception needs to be kept in sync with allowing
299
- // `#[target_feature]` on `main` and `start`.
300
- } else if !tcx. features ( ) . target_feature_11 {
301
- let mut err = feature_err (
302
- & tcx. sess . parse_sess ,
303
- sym:: target_feature_11,
304
- attr. span ,
305
- "`#[target_feature(..)]` can only be applied to `unsafe` functions" ,
306
- ) ;
307
- err. span_label ( tcx. def_span ( did) , "not an `unsafe` function" ) ;
308
- err. emit ( ) ;
297
+ // Now that `#[target_feature]` is permitted on safe functions,
298
+ // this exception must still exist for allowing the attribute on
299
+ // `main`, `start`, and other functions that are not usually
300
+ // allowed.
309
301
} else {
310
302
check_target_feature_trait_unsafe ( tcx, did, attr. span ) ;
311
303
}
@@ -535,10 +527,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
535
527
// its parent function, which effectively inherits the features anyway. Boxing this closure
536
528
// would result in this closure being compiled without the inherited target features, but this
537
529
// is probably a poor usage of `#[inline(always)]` and easily avoided by not using the attribute.
538
- if tcx. features ( ) . target_feature_11
539
- && tcx. is_closure ( did. to_def_id ( ) )
540
- && codegen_fn_attrs. inline != InlineAttr :: Always
541
- {
530
+ if tcx. is_closure ( did. to_def_id ( ) ) && codegen_fn_attrs. inline != InlineAttr :: Always {
542
531
let owner_id = tcx. parent ( did. to_def_id ( ) ) ;
543
532
if tcx. def_kind ( owner_id) . has_codegen_attrs ( ) {
544
533
codegen_fn_attrs
0 commit comments