@@ -3,7 +3,7 @@ use clippy_utils::ty::{is_type_diagnostic_item, is_type_lang_item};
3
3
use clippy_utils:: visitors:: for_each_expr_with_closures;
4
4
use clippy_utils:: { get_enclosing_block, path_to_local_id} ;
5
5
use core:: ops:: ControlFlow ;
6
- use rustc_hir:: { Block , ExprKind , HirId , LangItem , Local , Node , PatKind } ;
6
+ use rustc_hir:: { Block , ExprKind , HirId , LangItem , LetStmt , Node , PatKind } ;
7
7
use rustc_lint:: { LateContext , LateLintPass } ;
8
8
use rustc_session:: declare_lint_pass;
9
9
use rustc_span:: symbol:: sym;
@@ -58,7 +58,7 @@ static COLLECTIONS: [Symbol; 9] = [
58
58
] ;
59
59
60
60
impl < ' tcx > LateLintPass < ' tcx > for CollectionIsNeverRead {
61
- fn check_local ( & mut self , cx : & LateContext < ' tcx > , local : & ' tcx Local < ' tcx > ) {
61
+ fn check_local ( & mut self , cx : & LateContext < ' tcx > , local : & ' tcx LetStmt < ' tcx > ) {
62
62
// Look for local variables whose type is a container. Search surrounding bock for read access.
63
63
if match_acceptable_type ( cx, local, & COLLECTIONS )
64
64
&& let PatKind :: Binding ( _, local_id, _, _) = local. pat . kind
@@ -70,7 +70,7 @@ impl<'tcx> LateLintPass<'tcx> for CollectionIsNeverRead {
70
70
}
71
71
}
72
72
73
- fn match_acceptable_type ( cx : & LateContext < ' _ > , local : & Local < ' _ > , collections : & [ rustc_span:: Symbol ] ) -> bool {
73
+ fn match_acceptable_type ( cx : & LateContext < ' _ > , local : & LetStmt < ' _ > , collections : & [ rustc_span:: Symbol ] ) -> bool {
74
74
let ty = cx. typeck_results ( ) . pat_ty ( local. pat ) ;
75
75
collections. iter ( ) . any ( |& sym| is_type_diagnostic_item ( cx, ty, sym) )
76
76
// String type is a lang item but not a diagnostic item for now so we need a separate check
0 commit comments