mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
183 lines
6.1 KiB
Text
183 lines
6.1 KiB
Text
error: indexing into a slice multiple times without an `assert`
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:5
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: consider asserting the length before indexing: `assert!(v.len() > 4);`
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:5
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:12
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:19
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:26
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:33
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
= note: asserting the length before indexing will elide bounds checks
|
|
= note: `-D clippy::missing-asserts-for-indexing` implied by `-D warnings`
|
|
= help: to override `-D warnings` add `#[allow(clippy::missing_asserts_for_indexing)]`
|
|
|
|
error: indexing into a slice multiple times without an `assert`
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:10:13
|
|
|
|
|
LL | let _ = v[0];
|
|
| _____________^
|
|
LL | |
|
|
LL | | let _ = v[1..4];
|
|
| |___________________^
|
|
|
|
|
= help: consider asserting the length before indexing: `assert!(v.len() > 3);`
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:10:13
|
|
|
|
|
LL | let _ = v[0];
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:12:13
|
|
|
|
|
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:16:13
|
|
|
|
|
LL | let a = v[0];
|
|
| _____________^
|
|
LL | |
|
|
LL | | let b = v[1];
|
|
LL | | let c = v[2];
|
|
| |________________^
|
|
|
|
|
= help: consider asserting the length before indexing: `assert!(v.len() > 2);`
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:16:13
|
|
|
|
|
LL | let a = v[0];
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:18:13
|
|
|
|
|
LL | let b = v[1];
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:19:13
|
|
|
|
|
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:24:13
|
|
|
|
|
LL | let _ = v1[0] + v1[12];
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
= help: consider asserting the length before indexing: `assert!(v1.len() > 12);`
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:24:13
|
|
|
|
|
LL | let _ = v1[0] + v1[12];
|
|
| ^^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:24:21
|
|
|
|
|
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:25:13
|
|
|
|
|
LL | let _ = v2[5] + v2[15];
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
= help: consider asserting the length before indexing: `assert!(v2.len() > 15);`
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:25:13
|
|
|
|
|
LL | let _ = v2[5] + v2[15];
|
|
| ^^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:25:21
|
|
|
|
|
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:31:13
|
|
|
|
|
LL | let _ = v2[5] + v2[15];
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
= help: consider asserting the length before indexing: `assert!(v2.len() > 15);`
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:31:13
|
|
|
|
|
LL | let _ = v2[5] + v2[15];
|
|
| ^^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:31:21
|
|
|
|
|
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:40:13
|
|
|
|
|
LL | let _ = f.v[0] + f.v[1];
|
|
| ^^^^^^^^^^^^^^^
|
|
|
|
|
= help: consider asserting the length before indexing: `assert!(f.v.len() > 1);`
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:40:13
|
|
|
|
|
LL | let _ = f.v[0] + f.v[1];
|
|
| ^^^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:40:22
|
|
|
|
|
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:54:13
|
|
|
|
|
LL | let _ = x[0] + x[1];
|
|
| ^^^^^^^^^^^
|
|
|
|
|
= help: consider asserting the length before indexing: `assert!(x.len() > 1);`
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:54:13
|
|
|
|
|
LL | let _ = x[0] + x[1];
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing_unfixable.rs:54:20
|
|
|
|
|
LL | let _ = x[0] + x[1];
|
|
| ^^^^
|
|
= note: asserting the length before indexing will elide bounds checks
|
|
|
|
error: aborting due to 8 previous errors
|
|
|