From 5e88003ddac563a8ffc912d6e69332d479a92cc3 Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Fri, 28 Jul 2023 12:52:06 +0200 Subject: [PATCH] pattern match on local usage slice to avoid ICE --- clippy_lints/src/methods/readonly_write_lock.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/methods/readonly_write_lock.rs b/clippy_lints/src/methods/readonly_write_lock.rs index 404ded2b0137..e3ec921da0ce 100644 --- a/clippy_lints/src/methods/readonly_write_lock.rs +++ b/clippy_lints/src/methods/readonly_write_lock.rs @@ -29,12 +29,13 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, receiver && let Some((local, _)) = mir.local_decls.iter_enumerated().find(|(_, decl)| { local.span.contains(decl.source_info.span) }) - && let Some(usage) = visit_local_usage(&[local], mir, Location { + && let Some(usages) = visit_local_usage(&[local], mir, Location { block: START_BLOCK, statement_index: 0, }) + && let [usage] = usages.as_slice() { - let writer_never_mutated = usage[0].local_consume_or_mutate_locs.is_empty(); + let writer_never_mutated = usage.local_consume_or_mutate_locs.is_empty(); if writer_never_mutated { span_lint_and_sugg(