@@ -150,9 +150,9 @@ impl CheckAttrVisitor<'_> {
150
150
sym:: rustc_has_incoherent_inherent_impls => {
151
151
self . check_has_incoherent_inherent_impls ( & attr, span, target)
152
152
}
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 ) ,
156
156
sym:: rustc_const_unstable
157
157
| sym:: rustc_const_stable
158
158
| sym:: unstable
@@ -1174,8 +1174,8 @@ impl CheckAttrVisitor<'_> {
1174
1174
}
1175
1175
}
1176
1176
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 {
1179
1179
self . tcx . sess . emit_err ( errors:: FfiPureInvalidTarget { attr_span } ) ;
1180
1180
return false ;
1181
1181
}
@@ -1188,17 +1188,17 @@ impl CheckAttrVisitor<'_> {
1188
1188
}
1189
1189
}
1190
1190
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 {
1193
1193
true
1194
1194
} else {
1195
1195
self . tcx . sess . emit_err ( errors:: FfiConstInvalidTarget { attr_span } ) ;
1196
1196
false
1197
1197
}
1198
1198
}
1199
1199
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 {
1202
1202
true
1203
1203
} else {
1204
1204
self . tcx . sess . emit_err ( errors:: FfiReturnsTwiceInvalidTarget { attr_span } ) ;
0 commit comments