mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
305 lines
10 KiB
Text
305 lines
10 KiB
Text
error: indexing into a slice multiple times with an `assert` that does not cover the highest index
|
|
--> tests/ui/missing_asserts_for_indexing.rs:30:5
|
|
|
|
|
LL | assert!(v.len() < 5);
|
|
| -------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)`
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:30:5
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:30:12
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:30:19
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:30:26
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:30: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 with an `assert` that does not cover the highest index
|
|
--> tests/ui/missing_asserts_for_indexing.rs:36:5
|
|
|
|
|
LL | assert!(v.len() <= 5);
|
|
| --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)`
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:36:5
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:36:12
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:36:19
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:36:26
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:36:33
|
|
|
|
|
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
|
|
|
|
|
LL | assert!(v.len() > 3);
|
|
| -------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)`
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:42:5
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:42:12
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:42:19
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:42:26
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:42:33
|
|
|
|
|
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
|
|
|
|
|
LL | assert!(v.len() >= 4);
|
|
| --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)`
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:48:5
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:48:12
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:48:19
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:48:26
|
|
|
|
|
LL | v[0] + v[1] + v[2] + v[3] + v[4]
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:48:33
|
|
|
|
|
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
|
|
|
|
|
LL | assert!(v.len() >= 3);
|
|
| --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 3)`
|
|
LL | let _ = v[0];
|
|
| _____________^
|
|
LL | |
|
|
LL | | let _ = v[1..4];
|
|
| |___________________^
|
|
|
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:66:13
|
|
|
|
|
LL | let _ = v[0];
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:68:13
|
|
|
|
|
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:80:13
|
|
|
|
|
LL | assert!(v.len() >= 4);
|
|
| --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)`
|
|
LL | let _ = v[0];
|
|
| _____________^
|
|
LL | |
|
|
LL | | let _ = v[1..=4];
|
|
| |____________________^
|
|
|
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:80:13
|
|
|
|
|
LL | let _ = v[0];
|
|
| ^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:82:13
|
|
|
|
|
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:95:13
|
|
|
|
|
LL | assert!(v1.len() >= 12);
|
|
| ----------------------- help: provide the highest index that is indexed with: `assert!(v1.len() > 12)`
|
|
LL | assert!(v2.len() >= 15);
|
|
LL | let _ = v1[0] + v1[12];
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:95:13
|
|
|
|
|
LL | let _ = v1[0] + v1[12];
|
|
| ^^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:95:21
|
|
|
|
|
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:97:13
|
|
|
|
|
LL | assert!(v2.len() >= 15);
|
|
| ----------------------- help: provide the highest index that is indexed with: `assert!(v2.len() > 15)`
|
|
...
|
|
LL | let _ = v2[5] + v2[15];
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:97:13
|
|
|
|
|
LL | let _ = v2[5] + v2[15];
|
|
| ^^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:97:21
|
|
|
|
|
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:103:13
|
|
|
|
|
LL | assert!(v1.len() >= 12);
|
|
| ----------------------- help: provide the highest index that is indexed with: `assert!(v1.len() > 12)`
|
|
LL | assert!(v2.len() > 15);
|
|
LL | let _ = v1[0] + v1[12];
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:103:13
|
|
|
|
|
LL | let _ = v1[0] + v1[12];
|
|
| ^^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:103:21
|
|
|
|
|
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:127:13
|
|
|
|
|
LL | assert!(v1.len() == 2);
|
|
| ---------------------- help: provide the highest index that is indexed with: `assert!(v1.len() == 3)`
|
|
...
|
|
LL | let _ = v1[0] + v1[1] + v1[2];
|
|
| ^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:127:13
|
|
|
|
|
LL | let _ = v1[0] + v1[1] + v1[2];
|
|
| ^^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:127:21
|
|
|
|
|
LL | let _ = v1[0] + v1[1] + v1[2];
|
|
| ^^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:127:29
|
|
|
|
|
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:131:13
|
|
|
|
|
LL | assert!(2 == v3.len());
|
|
| ---------------------- help: provide the highest index that is indexed with: `assert!(v3.len() == 3)`
|
|
...
|
|
LL | let _ = v3[0] + v3[1] + v3[2];
|
|
| ^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:131:13
|
|
|
|
|
LL | let _ = v3[0] + v3[1] + v3[2];
|
|
| ^^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:131:21
|
|
|
|
|
LL | let _ = v3[0] + v3[1] + v3[2];
|
|
| ^^^^^
|
|
note: slice indexed here
|
|
--> tests/ui/missing_asserts_for_indexing.rs:131:29
|
|
|
|
|
LL | let _ = v3[0] + v3[1] + v3[2];
|
|
| ^^^^^
|
|
= note: asserting the length before indexing will elide bounds checks
|
|
|
|
error: aborting due to 11 previous errors
|
|
|