@@ -605,59 +605,66 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
605605 } ;
606606 check_abi ( tcx, it. hir_id ( ) , it. span , abi) ;
607607
608- if abi == Abi :: RustIntrinsic {
609- for item in items {
610- let item = tcx. hir ( ) . foreign_item ( item. id ) ;
611- intrinsic:: check_intrinsic_type ( tcx, item) ;
612- }
613- } else if abi == Abi :: PlatformIntrinsic {
614- for item in items {
615- let item = tcx. hir ( ) . foreign_item ( item. id ) ;
616- intrinsic:: check_platform_intrinsic_type ( tcx, item) ;
608+ match abi {
609+ Abi :: RustIntrinsic => {
610+ for item in items {
611+ let item = tcx. hir ( ) . foreign_item ( item. id ) ;
612+ intrinsic:: check_intrinsic_type ( tcx, item) ;
613+ }
617614 }
618- } else {
619- for item in items {
620- let def_id = item. id . owner_id . def_id ;
621- let generics = tcx. generics_of ( def_id) ;
622- let own_counts = generics. own_counts ( ) ;
623- if generics. params . len ( ) - own_counts. lifetimes != 0 {
624- let ( kinds, kinds_pl, egs) = match ( own_counts. types , own_counts. consts ) {
625- ( _, 0 ) => ( "type" , "types" , Some ( "u32" ) ) ,
626- // We don't specify an example value, because we can't generate
627- // a valid value for any type.
628- ( 0 , _) => ( "const" , "consts" , None ) ,
629- _ => ( "type or const" , "types or consts" , None ) ,
630- } ;
631- struct_span_err ! (
632- tcx. sess,
633- item. span,
634- E0044 ,
635- "foreign items may not have {kinds} parameters" ,
636- )
637- . span_label ( item. span , & format ! ( "can't have {kinds} parameters" ) )
638- . help (
639- // FIXME: once we start storing spans for type arguments, turn this
640- // into a suggestion.
641- & format ! (
642- "replace the {} parameters with concrete {}{}" ,
643- kinds,
644- kinds_pl,
645- egs. map( |egs| format!( " like `{}`" , egs) ) . unwrap_or_default( ) ,
646- ) ,
647- )
648- . emit ( ) ;
615+
616+ Abi :: PlatformIntrinsic => {
617+ for item in items {
618+ let item = tcx. hir ( ) . foreign_item ( item. id ) ;
619+ intrinsic:: check_platform_intrinsic_type ( tcx, item) ;
649620 }
621+ }
650622
651- let item = tcx. hir ( ) . foreign_item ( item. id ) ;
652- match & item. kind {
653- hir:: ForeignItemKind :: Fn ( fn_decl, _, _) => {
654- require_c_abi_if_c_variadic ( tcx, fn_decl, abi, item. span ) ;
623+ _ => {
624+ for item in items {
625+ let def_id = item. id . owner_id . def_id ;
626+ let generics = tcx. generics_of ( def_id) ;
627+ let own_counts = generics. own_counts ( ) ;
628+ if generics. params . len ( ) - own_counts. lifetimes != 0 {
629+ let ( kinds, kinds_pl, egs) = match ( own_counts. types , own_counts. consts )
630+ {
631+ ( _, 0 ) => ( "type" , "types" , Some ( "u32" ) ) ,
632+ // We don't specify an example value, because we can't generate
633+ // a valid value for any type.
634+ ( 0 , _) => ( "const" , "consts" , None ) ,
635+ _ => ( "type or const" , "types or consts" , None ) ,
636+ } ;
637+ struct_span_err ! (
638+ tcx. sess,
639+ item. span,
640+ E0044 ,
641+ "foreign items may not have {kinds} parameters" ,
642+ )
643+ . span_label ( item. span , & format ! ( "can't have {kinds} parameters" ) )
644+ . help (
645+ // FIXME: once we start storing spans for type arguments, turn this
646+ // into a suggestion.
647+ & format ! (
648+ "replace the {} parameters with concrete {}{}" ,
649+ kinds,
650+ kinds_pl,
651+ egs. map( |egs| format!( " like `{}`" , egs) ) . unwrap_or_default( ) ,
652+ ) ,
653+ )
654+ . emit ( ) ;
655655 }
656- hir:: ForeignItemKind :: Static ( ..) => {
657- check_static_inhabited ( tcx, def_id) ;
658- check_static_linkage ( tcx, def_id) ;
656+
657+ let item = tcx. hir ( ) . foreign_item ( item. id ) ;
658+ match & item. kind {
659+ hir:: ForeignItemKind :: Fn ( fn_decl, _, _) => {
660+ require_c_abi_if_c_variadic ( tcx, fn_decl, abi, item. span ) ;
661+ }
662+ hir:: ForeignItemKind :: Static ( ..) => {
663+ check_static_inhabited ( tcx, def_id) ;
664+ check_static_linkage ( tcx, def_id) ;
665+ }
666+ _ => { }
659667 }
660- _ => { }
661668 }
662669 }
663670 }
0 commit comments