@@ -741,10 +741,6 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
741741
742742 for & assoc_item in assoc_items. in_definition_order ( ) {
743743 match assoc_item. kind {
744- ty:: AssocKind :: Fn => {
745- let abi = tcx. fn_sig ( assoc_item. def_id ) . skip_binder ( ) . abi ( ) ;
746- forbid_intrinsic_abi ( tcx, assoc_item. ident ( tcx) . span , abi) ;
747- }
748744 ty:: AssocKind :: Type if assoc_item. defaultness ( tcx) . has_value ( ) => {
749745 let trait_args = GenericArgs :: identity_for_item ( tcx, def_id) ;
750746 let _: Result < _ , rustc_errors:: ErrorGuaranteed > = check_type_bounds (
@@ -788,65 +784,59 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
788784 } ;
789785 check_abi ( tcx, it. span , abi) ;
790786
791- match abi {
792- ExternAbi :: RustIntrinsic => {
793- for item in items {
794- intrinsic :: check_intrinsic_type (
795- tcx ,
796- item . id . owner_id . def_id ,
797- item. span ,
798- item. ident . name ,
799- abi ,
800- ) ;
801- }
787+ for item in items {
788+ let def_id = item . id . owner_id . def_id ;
789+
790+ if tcx . has_attr ( def_id , sym :: rustc_intrinsic ) {
791+ intrinsic :: check_intrinsic_type (
792+ tcx ,
793+ item. id . owner_id . def_id ,
794+ item. span ,
795+ item . ident . name ,
796+ abi ,
797+ ) ;
802798 }
803799
804- _ => {
805- for item in items {
806- let def_id = item. id . owner_id . def_id ;
807- let generics = tcx. generics_of ( def_id) ;
808- let own_counts = generics. own_counts ( ) ;
809- if generics. own_params . len ( ) - own_counts. lifetimes != 0 {
810- let ( kinds, kinds_pl, egs) = match ( own_counts. types , own_counts. consts )
811- {
812- ( _, 0 ) => ( "type" , "types" , Some ( "u32" ) ) ,
813- // We don't specify an example value, because we can't generate
814- // a valid value for any type.
815- ( 0 , _) => ( "const" , "consts" , None ) ,
816- _ => ( "type or const" , "types or consts" , None ) ,
817- } ;
818- struct_span_code_err ! (
819- tcx. dcx( ) ,
820- item. span,
821- E0044 ,
822- "foreign items may not have {kinds} parameters" ,
823- )
824- . with_span_label ( item. span , format ! ( "can't have {kinds} parameters" ) )
825- . with_help (
826- // FIXME: once we start storing spans for type arguments, turn this
827- // into a suggestion.
828- format ! (
829- "replace the {} parameters with concrete {}{}" ,
830- kinds,
831- kinds_pl,
832- egs. map( |egs| format!( " like `{egs}`" ) ) . unwrap_or_default( ) ,
833- ) ,
834- )
835- . emit ( ) ;
836- }
800+ let generics = tcx. generics_of ( def_id) ;
801+ let own_counts = generics. own_counts ( ) ;
802+ if generics. own_params . len ( ) - own_counts. lifetimes != 0 {
803+ let ( kinds, kinds_pl, egs) = match ( own_counts. types , own_counts. consts ) {
804+ ( _, 0 ) => ( "type" , "types" , Some ( "u32" ) ) ,
805+ // We don't specify an example value, because we can't generate
806+ // a valid value for any type.
807+ ( 0 , _) => ( "const" , "consts" , None ) ,
808+ _ => ( "type or const" , "types or consts" , None ) ,
809+ } ;
810+ struct_span_code_err ! (
811+ tcx. dcx( ) ,
812+ item. span,
813+ E0044 ,
814+ "foreign items may not have {kinds} parameters" ,
815+ )
816+ . with_span_label ( item. span , format ! ( "can't have {kinds} parameters" ) )
817+ . with_help (
818+ // FIXME: once we start storing spans for type arguments, turn this
819+ // into a suggestion.
820+ format ! (
821+ "replace the {} parameters with concrete {}{}" ,
822+ kinds,
823+ kinds_pl,
824+ egs. map( |egs| format!( " like `{egs}`" ) ) . unwrap_or_default( ) ,
825+ ) ,
826+ )
827+ . emit ( ) ;
828+ }
837829
838- let item = tcx. hir_foreign_item ( item. id ) ;
839- match & item. kind {
840- hir:: ForeignItemKind :: Fn ( sig, _, _) => {
841- require_c_abi_if_c_variadic ( tcx, sig. decl , abi, item. span ) ;
842- }
843- hir:: ForeignItemKind :: Static ( ..) => {
844- check_static_inhabited ( tcx, def_id) ;
845- check_static_linkage ( tcx, def_id) ;
846- }
847- _ => { }
848- }
830+ let item = tcx. hir_foreign_item ( item. id ) ;
831+ match & item. kind {
832+ hir:: ForeignItemKind :: Fn ( sig, _, _) => {
833+ require_c_abi_if_c_variadic ( tcx, sig. decl , abi, item. span ) ;
834+ }
835+ hir:: ForeignItemKind :: Static ( ..) => {
836+ check_static_inhabited ( tcx, def_id) ;
837+ check_static_linkage ( tcx, def_id) ;
849838 }
839+ _ => { }
850840 }
851841 }
852842 }
0 commit comments