File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
compiler/rustc_passes/src Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -368,11 +368,17 @@ impl CheckAttrVisitor<'tcx> {
368368 match target {
369369 Target :: Fn
370370 | Target :: Method ( MethodKind :: Trait { body : true } | MethodKind :: Inherent ) => true ,
371+
372+ // Allow foreign items for SIMD FFI.
373+ Target :: ForeignFn | Target :: ForeignMod | Target :: ForeignTy | Target :: ForeignStatic => {
374+ true
375+ }
376+
371377 // FIXME: #[target_feature] was previously erroneously allowed on statements and some
372378 // crates used this, so only emit a warning.
373379 Target :: Statement => {
374380 self . tcx . struct_span_lint_hir ( UNUSED_ATTRIBUTES , hir_id, attr. span , |lint| {
375- lint. build ( "attribute should be applied to a function" )
381+ lint. build ( "`#[target_feature]` attribute should be applied to a function" )
376382 . warn (
377383 "this was previously accepted by the compiler but is \
378384 being phased out; it will become a hard error in \
@@ -394,7 +400,10 @@ impl CheckAttrVisitor<'tcx> {
394400 _ => {
395401 self . tcx
396402 . sess
397- . struct_span_err ( attr. span , "attribute should be applied to a function" )
403+ . struct_span_err (
404+ attr. span ,
405+ "`#[target_feature]` attribute should be applied to a function" ,
406+ )
398407 . span_label ( * span, "not a function" )
399408 . emit ( ) ;
400409 false
You can’t perform that action at this time.
0 commit comments