@@ -6,7 +6,10 @@ extern crate rustc_span;
6
6
7
7
use clippy_utils:: { diagnostics:: span_lint, ty:: match_type, SpanlessEq } ;
8
8
use if_chain:: if_chain;
9
- use rustc_hir:: { intravisit:: { FnKind , Visitor , walk_expr} , Body , Expr , ExprKind , FnDecl , HirId } ;
9
+ use rustc_hir:: {
10
+ intravisit:: { walk_expr, FnKind , Visitor } ,
11
+ Body , Expr , ExprKind , FnDecl , HirId ,
12
+ } ;
10
13
use rustc_lint:: { LateContext , LateLintPass } ;
11
14
use rustc_span:: Span ;
12
15
use solana_lints:: { paths, utils:: visit_expr_no_bodies} ;
@@ -52,8 +55,8 @@ impl<'tcx> LateLintPass<'tcx> for MissingOwnerCheck {
52
55
cx,
53
56
MISSING_OWNER_CHECK ,
54
57
account_expr. span ,
55
- "this Account struct is used but there is no check on its owner field"
56
- )
58
+ "this Account struct is used but there is no check on its owner field" ,
59
+ ) ;
57
60
}
58
61
}
59
62
}
@@ -65,7 +68,10 @@ struct AccountUses<'cx, 'tcx> {
65
68
uses : Vec < & ' tcx Expr < ' tcx > > ,
66
69
}
67
70
68
- fn get_referenced_accounts < ' tcx > ( cx : & LateContext < ' tcx > , body : & ' tcx Body < ' tcx > ) -> Vec < & ' tcx Expr < ' tcx > > {
71
+ fn get_referenced_accounts < ' tcx > (
72
+ cx : & LateContext < ' tcx > ,
73
+ body : & ' tcx Body < ' tcx > ,
74
+ ) -> Vec < & ' tcx Expr < ' tcx > > {
69
75
let mut accounts = AccountUses {
70
76
cx,
71
77
uses : Vec :: new ( ) ,
@@ -87,20 +93,24 @@ impl<'cx, 'tcx> Visitor<'tcx> for AccountUses<'cx, 'tcx> {
87
93
self . uses. push( expr) ;
88
94
}
89
95
}
90
- walk_expr ( self , expr)
96
+ walk_expr ( self , expr) ;
91
97
}
92
98
}
93
99
94
100
fn contains_owner_use < ' tcx > (
95
- cx : & LateContext < ' tcx > ,
101
+ cx : & LateContext < ' tcx > ,
96
102
body : & ' tcx Body < ' tcx > ,
97
- account_expr : & Expr < ' tcx >
103
+ account_expr : & Expr < ' tcx > ,
98
104
) -> bool {
99
105
visit_expr_no_bodies ( & body. value , |expr| uses_owner_field ( cx, expr, account_expr) )
100
106
}
101
107
102
108
/// Checks if `expr` is an owner field reference on `account_expr`
103
- fn uses_owner_field < ' tcx > ( cx : & LateContext < ' tcx > , expr : & Expr < ' tcx > , account_expr : & Expr < ' tcx > ) -> bool {
109
+ fn uses_owner_field < ' tcx > (
110
+ cx : & LateContext < ' tcx > ,
111
+ expr : & Expr < ' tcx > ,
112
+ account_expr : & Expr < ' tcx > ,
113
+ ) -> bool {
104
114
if_chain ! {
105
115
if let ExprKind :: Field ( object, field_name) = expr. kind;
106
116
// TODO: add check for key, is_signer
0 commit comments