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