1
- use rustc:: hir;
2
1
use rustc:: hir:: intravisit;
2
+ use rustc:: hir;
3
3
use rustc:: lint:: * ;
4
4
use rustc:: ty:: { TypeAndMut , TyRef } ;
5
5
use utils:: { in_external_macro, recover_for_loop, span_lint} ;
@@ -28,14 +28,8 @@ impl LintPass for MutMut {
28
28
}
29
29
30
30
impl LateLintPass for MutMut {
31
- fn check_block ( & mut self , cx : & LateContext , block : & hir:: Block ) {
32
- intravisit:: walk_block ( & mut MutVisitor { cx : cx } , block) ;
33
- }
34
-
35
- fn check_ty ( & mut self , cx : & LateContext , ty : & hir:: Ty ) {
36
- use rustc:: hir:: intravisit:: Visitor ;
37
-
38
- MutVisitor { cx : cx } . visit_ty ( ty) ;
31
+ fn check_crate ( & mut self , cx : & LateContext , krate : & hir:: Crate ) {
32
+ krate. visit_all_items ( & mut MutVisitor { cx : cx } ) ;
39
33
}
40
34
}
41
35
@@ -58,6 +52,7 @@ impl<'a, 'tcx, 'v> intravisit::Visitor<'v> for MutVisitor<'a, 'tcx> {
58
52
// Let's ignore the generated code.
59
53
intravisit:: walk_expr ( self , arg) ;
60
54
intravisit:: walk_expr ( self , body) ;
55
+ return ;
61
56
} else if let hir:: ExprAddrOf ( hir:: MutMutable , ref e) = expr. node {
62
57
if let hir:: ExprAddrOf ( hir:: MutMutable , _) = e. node {
63
58
span_lint ( self . cx , MUT_MUT , expr. span , "generally you want to avoid `&mut &mut _` if possible" ) ;
@@ -68,6 +63,8 @@ impl<'a, 'tcx, 'v> intravisit::Visitor<'v> for MutVisitor<'a, 'tcx> {
68
63
"this expression mutably borrows a mutable reference. Consider reborrowing" ) ;
69
64
}
70
65
}
66
+
67
+ intravisit:: walk_expr ( self , expr) ;
71
68
}
72
69
73
70
fn visit_ty ( & mut self , ty : & hir:: Ty ) {
0 commit comments