@@ -249,10 +249,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
249249 {
250250 if tcx. sess . target . is_like_wasm || tcx. sess . opts . actually_rustdoc {
251251 // 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
256255 // execution of instructions that are not supported is
257256 // considered undefined behavior. For WebAssembly which is a
258257 // 100% safe target at execution time it's not possible to
@@ -266,17 +265,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
266265 // if a target is documenting some wasm-specific code then
267266 // it's not spuriously denied.
268267 //
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.
280272 } else {
281273 check_target_feature_trait_unsafe ( tcx, did, attr. span ) ;
282274 }
@@ -584,10 +576,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
584576 // its parent function, which effectively inherits the features anyway. Boxing this closure
585577 // would result in this closure being compiled without the inherited target features, but this
586578 // 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 {
591580 let owner_id = tcx. parent ( did. to_def_id ( ) ) ;
592581 if tcx. def_kind ( owner_id) . has_codegen_attrs ( ) {
593582 codegen_fn_attrs
0 commit comments