From 9ced0f5892eaff77f7b707fbd41be92d38b42028 Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Thu, 20 Nov 2025 12:58:16 +0100 Subject: [PATCH] use `note_once` This is a general advice, and so shouldn't be repeated --- clippy_lints/src/missing_asserts_for_indexing.rs | 2 +- tests/ui/missing_asserts_for_indexing.stderr | 14 -------------- .../missing_asserts_for_indexing_unfixable.stderr | 9 --------- 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/clippy_lints/src/missing_asserts_for_indexing.rs b/clippy_lints/src/missing_asserts_for_indexing.rs index 9e9aa5ffc544..ea65aa274dc4 100644 --- a/clippy_lints/src/missing_asserts_for_indexing.rs +++ b/clippy_lints/src/missing_asserts_for_indexing.rs @@ -76,7 +76,7 @@ fn report_lint(cx: &LateContext<'_>, full_span: Span, msg: &'static str, inde for span in indexes { diag.span_note(span, "slice indexed here"); } - diag.note("asserting the length before indexing will elide bounds checks"); + diag.note_once("asserting the length before indexing will elide bounds checks"); }); } diff --git a/tests/ui/missing_asserts_for_indexing.stderr b/tests/ui/missing_asserts_for_indexing.stderr index b686eda7530a..d6eef15c0448 100644 --- a/tests/ui/missing_asserts_for_indexing.stderr +++ b/tests/ui/missing_asserts_for_indexing.stderr @@ -68,7 +68,6 @@ note: slice indexed here | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:42:5 @@ -103,7 +102,6 @@ note: slice indexed here | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:48:5 @@ -138,7 +136,6 @@ note: slice indexed here | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:66:13 @@ -161,7 +158,6 @@ note: slice indexed here | LL | let _ = v[1..4]; | ^^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:81:13 @@ -184,7 +180,6 @@ note: slice indexed here | LL | let _ = v[1..=4]; | ^^^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:97:13 @@ -205,7 +200,6 @@ note: slice indexed here | LL | let _ = v1[0] + v1[12]; | ^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:100:13 @@ -226,7 +220,6 @@ note: slice indexed here | LL | let _ = v2[5] + v2[15]; | ^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:106:13 @@ -247,7 +240,6 @@ note: slice indexed here | LL | let _ = v1[0] + v1[12]; | ^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:131:13 @@ -273,7 +265,6 @@ note: slice indexed here | LL | let _ = v1[0] + v1[1] + v1[2]; | ^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:136:13 @@ -299,7 +290,6 @@ note: slice indexed here | LL | let _ = v3[0] + v3[1] + v3[2]; | ^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:158:13 @@ -325,7 +315,6 @@ note: slice indexed here | LL | let _ = v1[0] + v1[1] + v1[2]; | ^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:163:13 @@ -351,7 +340,6 @@ note: slice indexed here | LL | let _ = v3[0] + v3[1] + v3[2]; | ^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:172:17 @@ -376,7 +364,6 @@ note: slice indexed here | LL | let _ = v[0] + v[1] + v[2]; | ^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index --> tests/ui/missing_asserts_for_indexing.rs:178:17 @@ -401,7 +388,6 @@ note: slice indexed here | LL | let _ = v[0] + v[1] + v[2]; | ^^^^ - = note: asserting the length before indexing will elide bounds checks error: aborting due to 15 previous errors diff --git a/tests/ui/missing_asserts_for_indexing_unfixable.stderr b/tests/ui/missing_asserts_for_indexing_unfixable.stderr index a17ad0232138..aec64857a699 100644 --- a/tests/ui/missing_asserts_for_indexing_unfixable.stderr +++ b/tests/ui/missing_asserts_for_indexing_unfixable.stderr @@ -54,7 +54,6 @@ note: slice indexed here | LL | let _ = v[1..4]; | ^^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:17:13 @@ -83,7 +82,6 @@ note: slice indexed here | LL | let c = v[2]; | ^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:26:13 @@ -102,7 +100,6 @@ note: slice indexed here | LL | let _ = v1[0] + v1[12]; | ^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:28:13 @@ -121,7 +118,6 @@ note: slice indexed here | LL | let _ = v2[5] + v2[15]; | ^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:35:13 @@ -140,7 +136,6 @@ note: slice indexed here | LL | let _ = v2[5] + v2[15]; | ^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:45:13 @@ -159,7 +154,6 @@ note: slice indexed here | LL | let _ = f.v[0] + f.v[1]; | ^^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:59:13 @@ -178,7 +172,6 @@ note: slice indexed here | LL | let _ = x[0] + x[1]; | ^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:77:13 @@ -197,7 +190,6 @@ note: slice indexed here | LL | let _ = v1[1] + v1[2]; | ^^^^^ - = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` --> tests/ui/missing_asserts_for_indexing_unfixable.rs:85:13 @@ -221,7 +213,6 @@ note: slice indexed here | LL | let _ = v1[0] + v1[1] + v1[2]; | ^^^^^ - = note: asserting the length before indexing will elide bounds checks error: aborting due to 10 previous errors