Skip to content

Commit 5e88003

Browse files
committed
pattern match on local usage slice to avoid ICE
1 parent 205a374 commit 5e88003

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clippy_lints/src/methods/readonly_write_lock.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, receiver
2929
&& let Some((local, _)) = mir.local_decls.iter_enumerated().find(|(_, decl)| {
3030
local.span.contains(decl.source_info.span)
3131
})
32-
&& let Some(usage) = visit_local_usage(&[local], mir, Location {
32+
&& let Some(usages) = visit_local_usage(&[local], mir, Location {
3333
block: START_BLOCK,
3434
statement_index: 0,
3535
})
36+
&& let [usage] = usages.as_slice()
3637
{
37-
let writer_never_mutated = usage[0].local_consume_or_mutate_locs.is_empty();
38+
let writer_never_mutated = usage.local_consume_or_mutate_locs.is_empty();
3839

3940
if writer_never_mutated {
4041
span_lint_and_sugg(

0 commit comments

Comments
 (0)