@@ -150,9 +150,9 @@ impl CheckAttrVisitor<'_> {
150150 sym:: rustc_has_incoherent_inherent_impls => {
151151 self . check_has_incoherent_inherent_impls ( & attr, span, target)
152152 }
153- sym:: ffi_pure => self . check_ffi_pure ( hir_id , attr. span , attrs) ,
154- sym:: ffi_const => self . check_ffi_const ( hir_id , attr. span ) ,
155- sym:: ffi_returns_twice => self . check_ffi_returns_twice ( hir_id , attr. span ) ,
153+ sym:: ffi_pure => self . check_ffi_pure ( attr. span , attrs, target ) ,
154+ sym:: ffi_const => self . check_ffi_const ( attr. span , target ) ,
155+ sym:: ffi_returns_twice => self . check_ffi_returns_twice ( attr. span , target ) ,
156156 sym:: rustc_const_unstable
157157 | sym:: rustc_const_stable
158158 | sym:: unstable
@@ -1174,8 +1174,8 @@ impl CheckAttrVisitor<'_> {
11741174 }
11751175 }
11761176
1177- fn check_ffi_pure ( & self , hir_id : HirId , attr_span : Span , attrs : & [ Attribute ] ) -> bool {
1178- if ! self . tcx . is_foreign_item ( self . tcx . hir ( ) . local_def_id ( hir_id ) ) {
1177+ fn check_ffi_pure ( & self , attr_span : Span , attrs : & [ Attribute ] , target : Target ) -> bool {
1178+ if target != Target :: ForeignFn {
11791179 self . tcx . sess . emit_err ( errors:: FfiPureInvalidTarget { attr_span } ) ;
11801180 return false ;
11811181 }
@@ -1188,17 +1188,17 @@ impl CheckAttrVisitor<'_> {
11881188 }
11891189 }
11901190
1191- fn check_ffi_const ( & self , hir_id : HirId , attr_span : Span ) -> bool {
1192- if self . tcx . is_foreign_item ( self . tcx . hir ( ) . local_def_id ( hir_id ) ) {
1191+ fn check_ffi_const ( & self , attr_span : Span , target : Target ) -> bool {
1192+ if target == Target :: ForeignFn {
11931193 true
11941194 } else {
11951195 self . tcx . sess . emit_err ( errors:: FfiConstInvalidTarget { attr_span } ) ;
11961196 false
11971197 }
11981198 }
11991199
1200- fn check_ffi_returns_twice ( & self , hir_id : HirId , attr_span : Span ) -> bool {
1201- if self . tcx . is_foreign_item ( self . tcx . hir ( ) . local_def_id ( hir_id ) ) {
1200+ fn check_ffi_returns_twice ( & self , attr_span : Span , target : Target ) -> bool {
1201+ if target == Target :: ForeignFn {
12021202 true
12031203 } else {
12041204 self . tcx . sess . emit_err ( errors:: FfiReturnsTwiceInvalidTarget { attr_span } ) ;
0 commit comments