1
1
use rustc_abi:: ExternAbi ;
2
- use rustc_hir:: { self as hir, intravisit} ;
2
+ use rustc_hir as hir;
3
+ use rustc_hir:: def_id:: LocalDefId ;
4
+ use rustc_hir:: intravisit:: FnKind ;
3
5
use rustc_lint:: LateContext ;
4
6
use rustc_span:: Span ;
5
7
@@ -10,39 +12,18 @@ use super::TOO_MANY_ARGUMENTS;
10
12
11
13
pub ( super ) fn check_fn (
12
14
cx : & LateContext < ' _ > ,
13
- kind : intravisit :: FnKind < ' _ > ,
15
+ kind : FnKind < ' _ > ,
14
16
decl : & hir:: FnDecl < ' _ > ,
15
- span : Span ,
16
17
hir_id : hir:: HirId ,
18
+ def_id : LocalDefId ,
17
19
too_many_arguments_threshold : u64 ,
18
20
) {
19
21
// don't warn for implementations, it's not their fault
20
- if !is_trait_impl_item ( cx, hir_id) {
22
+ if !is_trait_impl_item ( cx, hir_id)
21
23
// don't lint extern functions decls, it's not their fault either
22
- match kind {
23
- intravisit:: FnKind :: Method (
24
- _,
25
- & hir:: FnSig {
26
- header : hir:: FnHeader {
27
- abi : ExternAbi :: Rust , ..
28
- } ,
29
- ..
30
- } ,
31
- )
32
- | intravisit:: FnKind :: ItemFn (
33
- _,
34
- _,
35
- hir:: FnHeader {
36
- abi : ExternAbi :: Rust , ..
37
- } ,
38
- ) => check_arg_number (
39
- cx,
40
- decl,
41
- span. with_hi ( decl. output . span ( ) . hi ( ) ) ,
42
- too_many_arguments_threshold,
43
- ) ,
44
- _ => { } ,
45
- }
24
+ && kind. header ( ) . is_some_and ( |header| header. abi == ExternAbi :: Rust )
25
+ {
26
+ check_arg_number ( cx, decl, cx. tcx . def_span ( def_id) , too_many_arguments_threshold) ;
46
27
}
47
28
}
48
29
0 commit comments