Skip to content

Commit 1f530ab

Browse files
committed
Refactor collection_is_never_read: Check HIR tree before checking types.
1 parent 39cd58e commit 1f530ab

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

clippy_lints/src/collection_is_never_read.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ static COLLECTIONS: [Symbol; 9] = [
5959

6060
impl<'tcx> LateLintPass<'tcx> for CollectionIsNeverRead {
6161
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx LetStmt<'tcx>) {
62-
// Look for local variables whose type is a container. Search surrounding bock for read access.
63-
if match_acceptable_type(cx, local, &COLLECTIONS)
64-
&& let PatKind::Binding(_, local_id, _, _) = local.pat.kind
62+
// Look for local variables whose type is a container. Search surrounding block for read access.
63+
if let PatKind::Binding(_, local_id, _, _) = local.pat.kind
64+
&& match_acceptable_type(cx, local, &COLLECTIONS)
6565
&& let Some(enclosing_block) = get_enclosing_block(cx, local.hir_id)
6666
&& has_no_read_access(cx, local_id, enclosing_block)
6767
{

0 commit comments

Comments
 (0)