@@ -260,10 +260,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
260260 if safe_target_features {
261261 if tcx. sess . target . is_like_wasm || tcx. sess . opts . actually_rustdoc {
262262 // The `#[target_feature]` attribute is allowed on
263- // WebAssembly targets on all functions, including safe
264- // ones. Other targets require that `#[target_feature]` is
265- // only applied to unsafe functions (pending the
266- // `target_feature_11` feature) because on most targets
263+ // WebAssembly targets on all functions. Prior to stabilizing
264+ // the `target_feature_11` feature, `#[target_feature]` was
265+ // only permitted on unsafe functions because on most targets
267266 // execution of instructions that are not supported is
268267 // considered undefined behavior. For WebAssembly which is a
269268 // 100% safe target at execution time it's not possible to
@@ -277,17 +276,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
277276 // if a target is documenting some wasm-specific code then
278277 // it's not spuriously denied.
279278 //
280- // This exception needs to be kept in sync with allowing
281- // `#[target_feature]` on `main` and `start`.
282- } else if !tcx. features ( ) . target_feature_11 ( ) {
283- feature_err (
284- & tcx. sess ,
285- sym:: target_feature_11,
286- attr. span ,
287- "`#[target_feature(..)]` can only be applied to `unsafe` functions" ,
288- )
289- . with_span_label ( tcx. def_span ( did) , "not an `unsafe` function" )
290- . emit ( ) ;
279+ // Now that `#[target_feature]` is permitted on safe functions,
280+ // this exception must still exist for allowing the attribute on
281+ // `main`, `start`, and other functions that are not usually
282+ // allowed.
291283 } else {
292284 check_target_feature_trait_unsafe ( tcx, did, attr. span ) ;
293285 }
@@ -616,10 +608,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
616608 // its parent function, which effectively inherits the features anyway. Boxing this closure
617609 // would result in this closure being compiled without the inherited target features, but this
618610 // is probably a poor usage of `#[inline(always)]` and easily avoided by not using the attribute.
619- if tcx. features ( ) . target_feature_11 ( )
620- && tcx. is_closure_like ( did. to_def_id ( ) )
621- && !codegen_fn_attrs. inline . always ( )
622- {
611+ if tcx. is_closure_like ( did. to_def_id ( ) ) && codegen_fn_attrs. inline != InlineAttr :: Always {
623612 let owner_id = tcx. parent ( did. to_def_id ( ) ) ;
624613 if tcx. def_kind ( owner_id) . has_codegen_attrs ( ) {
625614 codegen_fn_attrs
0 commit comments