@@ -640,27 +640,31 @@ impl LintPass for ImproperCTypes {
640
640
}
641
641
}
642
642
643
- impl LateLintPass for ImproperCTypes {
644
- fn check_item ( & mut self , cx : & LateContext , it : & hir:: Item ) {
645
- fn check_ty ( cx : & LateContext , ty : & hir:: Ty ) {
646
- let mut vis = ImproperCTypesVisitor { cx : cx } ;
647
- vis. visit_ty ( ty) ;
648
- }
643
+ fn check_ty ( cx : & LateContext , ty : & hir:: Ty ) {
644
+ let mut vis = ImproperCTypesVisitor { cx : cx } ;
645
+ vis. visit_ty ( ty) ;
646
+ }
649
647
650
- fn check_foreign_fn ( cx : & LateContext , decl : & hir:: FnDecl ) {
651
- for input in & decl. inputs {
652
- check_ty ( cx, & * input. ty ) ;
653
- }
654
- if let hir:: Return ( ref ret_ty) = decl. output {
655
- let tty = ast_ty_to_normalized ( cx. tcx , ret_ty. id ) ;
656
- if !tty. is_nil ( ) {
657
- check_ty ( cx, & ret_ty) ;
658
- }
659
- }
648
+ fn check_foreign_fn ( cx : & LateContext , decl : & hir:: FnDecl ) {
649
+ for input in & decl. inputs {
650
+ check_ty ( cx, & * input. ty ) ;
651
+ }
652
+ if let hir:: Return ( ref ret_ty) = decl. output {
653
+ let tty = ast_ty_to_normalized ( cx. tcx , ret_ty. id ) ;
654
+ if !tty. is_nil ( ) {
655
+ check_ty ( cx, & ret_ty) ;
660
656
}
657
+ }
658
+ }
661
659
660
+ fn should_check_abi ( abi : abi:: Abi ) -> bool {
661
+ ![ abi:: RustIntrinsic , abi:: PlatformIntrinsic ] . contains ( & abi)
662
+ }
663
+
664
+ impl LateLintPass for ImproperCTypes {
665
+ fn check_item ( & mut self , cx : & LateContext , it : & hir:: Item ) {
662
666
if let hir:: ItemForeignMod ( ref nmod) = it. node {
663
- if nmod. abi != abi :: RustIntrinsic && nmod . abi != abi :: PlatformIntrinsic {
667
+ if should_check_abi ( nmod. abi ) {
664
668
for ni in & nmod. items {
665
669
match ni. node {
666
670
hir:: ForeignItemFn ( ref decl, _) => check_foreign_fn ( cx, & * * decl) ,
0 commit comments