Skip to content

Commit cc3d5e3

Browse files
committed
improper_ctypes: also check extern fn's
closes rust-lang#19834
1 parent 9953eaf commit cc3d5e3

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/librustc_lint/types.rs

+19-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ use syntax::{abi, ast};
2525
use syntax::attr::{self, AttrMetaMethods};
2626
use syntax::codemap::{self, Span};
2727
use syntax::feature_gate::{emit_feature_err, GateIssue};
28-
use syntax::ast::{TyIs, TyUs, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
28+
use syntax::ast::{NodeId, TyIs, TyUs, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
2929

3030
use rustc_front::hir;
31-
use rustc_front::intravisit::{self, Visitor};
31+
use rustc_front::intravisit::{self, FnKind, Visitor};
3232
use rustc_front::util::is_shift_binop;
3333

3434
declare_lint! {
@@ -674,4 +674,21 @@ impl LateLintPass for ImproperCTypes {
674674
}
675675
}
676676
}
677+
678+
fn check_fn(&mut self, cx: &LateContext,
679+
kind: FnKind,
680+
decl: &hir::FnDecl,
681+
_: &hir::Block,
682+
_: Span,
683+
_: NodeId) {
684+
let abi = match kind {
685+
FnKind::ItemFn(_, _, _, _, abi, _) => abi,
686+
FnKind::Method(_, sig, _) => sig.abi,
687+
FnKind::Closure => return,
688+
};
689+
690+
if should_check_abi(abi) {
691+
check_foreign_fn(cx, decl);
692+
}
693+
}
677694
}

0 commit comments

Comments
 (0)