@@ -255,10 +255,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
255255 {
256256 if tcx. sess . target . is_like_wasm || tcx. sess . opts . actually_rustdoc {
257257 // The `#[target_feature]` attribute is allowed on
258- // WebAssembly targets on all functions, including safe
259- // ones. Other targets require that `#[target_feature]` is
260- // only applied to unsafe functions (pending the
261- // `target_feature_11` feature) because on most targets
258+ // WebAssembly targets on all functions. Prior to stabilizing
259+ // the `target_feature_11` feature, `#[target_feature]` was
260+ // only permitted on safe functions because on most targets
262261 // execution of instructions that are not supported is
263262 // considered undefined behavior. For WebAssembly which is a
264263 // 100% safe target at execution time it's not possible to
@@ -272,17 +271,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
272271 // if a target is documenting some wasm-specific code then
273272 // it's not spuriously denied.
274273 //
275- // This exception needs to be kept in sync with allowing
276- // `#[target_feature]` on `main` and `start`.
277- } else if !tcx. features ( ) . target_feature_11 ( ) {
278- feature_err (
279- & tcx. sess ,
280- sym:: target_feature_11,
281- attr. span ,
282- "`#[target_feature(..)]` can only be applied to `unsafe` functions" ,
283- )
284- . with_span_label ( tcx. def_span ( did) , "not an `unsafe` function" )
285- . emit ( ) ;
274+ // Now that `#[target_feature]` is permitted on safe functions,
275+ // this exception must still exist for allowing the attribute on
276+ // `main`, `start`, and other functions that are not usually
277+ // allowed.
286278 } else {
287279 check_target_feature_trait_unsafe ( tcx, did, attr. span ) ;
288280 }
@@ -599,10 +591,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
599591 // its parent function, which effectively inherits the features anyway. Boxing this closure
600592 // would result in this closure being compiled without the inherited target features, but this
601593 // is probably a poor usage of `#[inline(always)]` and easily avoided by not using the attribute.
602- if tcx. features ( ) . target_feature_11 ( )
603- && tcx. is_closure_like ( did. to_def_id ( ) )
604- && codegen_fn_attrs. inline != InlineAttr :: Always
605- {
594+ if tcx. is_closure_like ( did. to_def_id ( ) ) && codegen_fn_attrs. inline != InlineAttr :: Always {
606595 let owner_id = tcx. parent ( did. to_def_id ( ) ) ;
607596 if tcx. def_kind ( owner_id) . has_codegen_attrs ( ) {
608597 codegen_fn_attrs
0 commit comments