Skip to content

Commit 6a14a52

Browse files
committed
clean-up: pass things by value to avoid copying
1 parent e567e30 commit 6a14a52

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

clippy_lints/src/missing_asserts_for_indexing.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ declare_clippy_lint! {
6767
}
6868
declare_lint_pass!(MissingAssertsForIndexing => [MISSING_ASSERTS_FOR_INDEXING]);
6969

70-
fn report_lint<F>(cx: &LateContext<'_>, full_span: Span, msg: &'static str, indexes: &[Span], f: F)
70+
fn report_lint<F>(cx: &LateContext<'_>, full_span: Span, msg: &'static str, indexes: Vec<Span>, f: F)
7171
where
7272
F: FnOnce(&mut Diag<'_, ()>),
7373
{
7474
span_lint_and_then(cx, MISSING_ASSERTS_FOR_INDEXING, full_span, msg, |diag| {
7575
f(diag);
7676
for span in indexes {
77-
diag.span_note(*span, "slice indexed here");
77+
diag.span_note(span, "slice indexed here");
7878
}
7979
diag.note("asserting the length before indexing will elide bounds checks");
8080
});
@@ -354,8 +354,8 @@ fn check_assert<'hir>(cx: &LateContext<'_>, expr: &'hir Expr<'hir>, map: &mut Un
354354
/// Inspects indexes and reports lints.
355355
///
356356
/// Called at the end of this lint after all indexing and `assert!` expressions have been collected.
357-
fn report_indexes(cx: &LateContext<'_>, map: &UnindexMap<u64, Vec<IndexEntry<'_>>>) {
358-
for bucket in map.values() {
357+
fn report_indexes(cx: &LateContext<'_>, map: UnindexMap<u64, Vec<IndexEntry<'_>>>) {
358+
for bucket in map.into_values() {
359359
for entry in bucket {
360360
let Some(full_span) = entry
361361
.index_spans()
@@ -365,12 +365,12 @@ fn report_indexes(cx: &LateContext<'_>, map: &UnindexMap<u64, Vec<IndexEntry<'_>
365365
continue;
366366
};
367367

368-
match *entry {
368+
match entry {
369369
IndexEntry::AssertWithIndex {
370370
highest_index,
371371
is_first_highest,
372372
asserted_len,
373-
ref indexes,
373+
indexes,
374374
comparison,
375375
assert_span,
376376
slice,
@@ -433,7 +433,7 @@ fn report_indexes(cx: &LateContext<'_>, map: &UnindexMap<u64, Vec<IndexEntry<'_>
433433
}
434434
},
435435
IndexEntry::IndexWithoutAssert {
436-
ref indexes,
436+
indexes,
437437
highest_index,
438438
is_first_highest,
439439
slice,
@@ -469,6 +469,6 @@ impl LateLintPass<'_> for MissingAssertsForIndexing {
469469
ControlFlow::<!, ()>::Continue(())
470470
});
471471

472-
report_indexes(cx, &map);
472+
report_indexes(cx, map);
473473
}
474474
}

0 commit comments

Comments
 (0)