@@ -17,16 +17,15 @@ mod variable_check;
17
17
use clippy_utils:: { get_parent_expr, get_trait_def_id} ;
18
18
use rustc_data_structures:: fx:: FxHashSet ;
19
19
use rustc_errors:: Applicability ;
20
- use rustc_hir:: intravisit:: Visitor ;
20
+ use rustc_hir:: intravisit:: { walk_expr , Visitor } ;
21
21
use rustc_hir:: { self as hir} ;
22
22
use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
23
- use rustc_middle:: ty:: { self , ty_kind :: TyKind , Ty } ;
23
+ use rustc_middle:: ty:: { self , Ty } ;
24
24
use rustc_span:: sym;
25
25
use variable_check:: {
26
26
check_implements_par_iter, check_trait_impl, check_variables, generate_suggestion,
27
27
is_type_valid,
28
28
} ;
29
-
30
29
dylint_linting:: declare_late_lint! {
31
30
/// ### What it does
32
31
/// parallelize iterators using rayon
@@ -89,11 +88,6 @@ impl<'tcx> LateLintPass<'tcx> for ParIter {
89
88
return ;
90
89
}
91
90
92
- // TODO: this needs to change and find a better solutions for returns
93
- if let TyKind :: Adt ( _, _) = ty. kind ( ) {
94
- return ;
95
- }
96
-
97
91
let mut validator = Validator { cx, is_valid : true } ;
98
92
validator. visit_expr ( top_expr) ;
99
93
if !validator. is_valid {
@@ -128,14 +122,17 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'_> for Validator<'a, 'tcx> {
128
122
if !self . is_valid {
129
123
return ;
130
124
}
125
+ let ex_ty = self . cx . typeck_results ( ) . expr_ty ( ex) ;
126
+ self . is_valid &= is_type_valid ( self . cx , ex_ty) ;
127
+
131
128
for arg in args {
132
129
if let hir:: ExprKind :: Closure ( closure) = arg. kind {
133
130
let body = self . cx . tcx . hir ( ) . body ( closure. body ) ;
134
-
135
131
self . is_valid &= check_variables ( self . cx , closure. def_id , body) ;
136
132
}
137
133
}
138
134
}
135
+ walk_expr ( self , ex)
139
136
}
140
137
}
141
138
0 commit comments