@@ -9,7 +9,9 @@ extern crate rustc_middle;
9
9
extern crate rustc_span;
10
10
11
11
use clippy_utils:: {
12
- diagnostics:: span_lint_and_help, get_trait_def_id, match_def_path, ty:: { match_type, implements_trait} ,
12
+ diagnostics:: span_lint_and_help,
13
+ get_trait_def_id, match_def_path,
14
+ ty:: { implements_trait, match_type} ,
13
15
} ;
14
16
use rustc_data_structures:: fx:: FxHashMap ;
15
17
use rustc_hir:: { def:: Res , Expr , ExprKind , QPath , TyKind } ;
@@ -64,18 +66,12 @@ struct TypeCosplay {
64
66
deser_types : FxHashMap < AdtKind , Vec < ( DefId , Span ) > > ,
65
67
}
66
68
67
- // get type X
68
- // check if implements Discriminator
69
- // check corresponding function call type:
70
- // if !try_deserialize
71
- // emit lint with warning to use try_deserialize (because any types deriving Discriminator should since it guaranteed to check discrim)
72
-
73
69
impl < ' tcx > LateLintPass < ' tcx > for TypeCosplay {
74
70
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' tcx > ) {
75
71
if_chain ! {
76
72
if !expr. span. from_expansion( ) ;
77
73
if let ExprKind :: Call ( fnc_expr, args_exprs) = expr. kind;
78
- // TODO: recommended case will exit early since it contains a reference to AccountInfo.data,
74
+ // TODO: recommended-2 case will exit early since it contains a reference to AccountInfo.data,
79
75
// not a direct argument. In general, any references will fail
80
76
if args_exprs. iter( ) . any( |arg| {
81
77
visit_expr_no_bodies( arg, |expr| contains_data_field_reference( cx, expr) )
@@ -259,3 +255,8 @@ fn secure_two() {
259
255
fn recommended ( ) {
260
256
dylint_testing:: ui_test_example ( env ! ( "CARGO_PKG_NAME" ) , "recommended" ) ;
261
257
}
258
+
259
+ #[ test]
260
+ fn recommended_2 ( ) {
261
+ dylint_testing:: ui_test_example ( env ! ( "CARGO_PKG_NAME" ) , "recommended-2" ) ;
262
+ }
0 commit comments