@@ -931,8 +931,8 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
931
931
932
932
check_abi ( tcx, it. hir_id ( ) , it. span , abi) ;
933
933
934
- for item in items {
935
- let def_id = item. id . owner_id . def_id ;
934
+ for & item in items {
935
+ let def_id = item. owner_id . def_id ;
936
936
937
937
let generics = tcx. generics_of ( def_id) ;
938
938
let own_counts = generics. own_counts ( ) ;
@@ -944,13 +944,14 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
944
944
( 0 , _) => ( "const" , "consts" , None ) ,
945
945
_ => ( "type or const" , "types or consts" , None ) ,
946
946
} ;
947
+ let span = tcx. def_span ( def_id) ;
947
948
struct_span_code_err ! (
948
949
tcx. dcx( ) ,
949
- item . span,
950
+ span,
950
951
E0044 ,
951
952
"foreign items may not have {kinds} parameters" ,
952
953
)
953
- . with_span_label ( item . span , format ! ( "can't have {kinds} parameters" ) )
954
+ . with_span_label ( span, format ! ( "can't have {kinds} parameters" ) )
954
955
. with_help (
955
956
// FIXME: once we start storing spans for type arguments, turn this
956
957
// into a suggestion.
@@ -964,22 +965,23 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
964
965
. emit ( ) ;
965
966
}
966
967
967
- let item = tcx. hir_foreign_item ( item. id ) ;
968
- tcx. ensure_ok ( ) . generics_of ( item. owner_id ) ;
969
- tcx. ensure_ok ( ) . type_of ( item. owner_id ) ;
970
- tcx. ensure_ok ( ) . predicates_of ( item. owner_id ) ;
968
+ tcx. ensure_ok ( ) . generics_of ( def_id) ;
969
+ tcx. ensure_ok ( ) . type_of ( def_id) ;
970
+ tcx. ensure_ok ( ) . predicates_of ( def_id) ;
971
971
if tcx. is_conditionally_const ( def_id) {
972
972
tcx. ensure_ok ( ) . explicit_implied_const_bounds ( def_id) ;
973
973
tcx. ensure_ok ( ) . const_conditions ( def_id) ;
974
974
}
975
- match item. kind {
976
- hir:: ForeignItemKind :: Fn ( sig, ..) => {
977
- tcx. ensure_ok ( ) . codegen_fn_attrs ( item. owner_id ) ;
978
- tcx. ensure_ok ( ) . fn_sig ( item. owner_id ) ;
975
+ match tcx. def_kind ( def_id) {
976
+ DefKind :: Fn => {
977
+ tcx. ensure_ok ( ) . codegen_fn_attrs ( def_id) ;
978
+ tcx. ensure_ok ( ) . fn_sig ( def_id) ;
979
+ let item = tcx. hir_foreign_item ( item) ;
980
+ let hir:: ForeignItemKind :: Fn ( sig, ..) = item. kind else { bug ! ( ) } ;
979
981
require_c_abi_if_c_variadic ( tcx, sig. decl , abi, item. span ) ;
980
982
}
981
- hir :: ForeignItemKind :: Static ( .. ) => {
982
- tcx. ensure_ok ( ) . codegen_fn_attrs ( item . owner_id ) ;
983
+ DefKind :: Static { .. } => {
984
+ tcx. ensure_ok ( ) . codegen_fn_attrs ( def_id ) ;
983
985
}
984
986
_ => ( ) ,
985
987
}
0 commit comments