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