|
1 | 1 | error: indexing into a slice multiple times with an `assert` that does not cover the highest index |
2 | 2 | --> tests/ui/missing_asserts_for_indexing.rs:30:5 |
3 | 3 | | |
4 | | -LL | assert!(v.len() < 5); |
5 | | - | -------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` |
6 | 4 | LL | v[0] + v[1] + v[2] + v[3] + v[4] |
7 | 5 | | ^^^^ ^^^^ ^^^^ ^^^^ ^^^^ |
8 | 6 | | |
9 | 7 | = note: asserting the length before indexing will elide bounds checks |
10 | 8 | = note: `-D clippy::missing-asserts-for-indexing` implied by `-D warnings` |
11 | 9 | = help: to override `-D warnings` add `#[allow(clippy::missing_asserts_for_indexing)]` |
| 10 | +help: provide the highest index that is indexed with |
| 11 | + | |
| 12 | +LL - assert!(v.len() < 5); |
| 13 | +LL + assert!(v.len() > 4); |
| 14 | + | |
12 | 15 |
|
13 | 16 | error: indexing into a slice multiple times with an `assert` that does not cover the highest index |
14 | 17 | --> tests/ui/missing_asserts_for_indexing.rs:36:5 |
15 | 18 | | |
16 | | -LL | assert!(v.len() <= 5); |
17 | | - | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` |
18 | 19 | LL | v[0] + v[1] + v[2] + v[3] + v[4] |
19 | 20 | | ^^^^ ^^^^ ^^^^ ^^^^ ^^^^ |
| 21 | + | |
| 22 | +help: provide the highest index that is indexed with |
| 23 | + | |
| 24 | +LL - assert!(v.len() <= 5); |
| 25 | +LL + assert!(v.len() > 4); |
| 26 | + | |
20 | 27 |
|
21 | 28 | error: indexing into a slice multiple times with an `assert` that does not cover the highest index |
22 | 29 | --> tests/ui/missing_asserts_for_indexing.rs:42:5 |
23 | 30 | | |
24 | | -LL | assert!(v.len() > 3); |
25 | | - | -------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` |
26 | 31 | LL | v[0] + v[1] + v[2] + v[3] + v[4] |
27 | 32 | | ^^^^ ^^^^ ^^^^ ^^^^ ^^^^ |
| 33 | + | |
| 34 | +help: provide the highest index that is indexed with |
| 35 | + | |
| 36 | +LL - assert!(v.len() > 3); |
| 37 | +LL + assert!(v.len() > 4); |
| 38 | + | |
28 | 39 |
|
29 | 40 | error: indexing into a slice multiple times with an `assert` that does not cover the highest index |
30 | 41 | --> tests/ui/missing_asserts_for_indexing.rs:48:5 |
31 | 42 | | |
32 | | -LL | assert!(v.len() >= 4); |
33 | | - | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` |
34 | 43 | LL | v[0] + v[1] + v[2] + v[3] + v[4] |
35 | 44 | | ^^^^ ^^^^ ^^^^ ^^^^ ^^^^ |
| 45 | + | |
| 46 | +help: provide the highest index that is indexed with |
| 47 | + | |
| 48 | +LL - assert!(v.len() >= 4); |
| 49 | +LL + assert!(v.len() > 4); |
| 50 | + | |
36 | 51 |
|
37 | 52 | error: indexing into a slice multiple times with an `assert` that does not cover the highest index |
38 | 53 | --> tests/ui/missing_asserts_for_indexing.rs:66:13 |
39 | 54 | | |
40 | | -LL | assert!(v.len() >= 3); |
41 | | - | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 3)` |
42 | 55 | LL | let _ = v[0]; |
43 | 56 | | ^^^^ |
44 | 57 | ... |
45 | 58 | LL | let _ = v[1..4]; |
46 | 59 | | ^^^^^^^ |
| 60 | + | |
| 61 | +help: provide the highest index that is indexed with |
| 62 | + | |
| 63 | +LL - assert!(v.len() >= 3); |
| 64 | +LL + assert!(v.len() > 3); |
| 65 | + | |
47 | 66 |
|
48 | 67 | error: indexing into a slice multiple times with an `assert` that does not cover the highest index |
49 | 68 | --> tests/ui/missing_asserts_for_indexing.rs:81:13 |
50 | 69 | | |
51 | | -LL | assert!(v.len() >= 4); |
52 | | - | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` |
53 | 70 | LL | let _ = v[0]; |
54 | 71 | | ^^^^ |
55 | 72 | ... |
56 | 73 | LL | let _ = v[1..=4]; |
57 | 74 | | ^^^^^^^^ |
| 75 | + | |
| 76 | +help: provide the highest index that is indexed with |
| 77 | + | |
| 78 | +LL - assert!(v.len() >= 4); |
| 79 | +LL + assert!(v.len() > 4); |
| 80 | + | |
58 | 81 |
|
59 | 82 | error: indexing into a slice multiple times with an `assert` that does not cover the highest index |
60 | 83 | --> tests/ui/missing_asserts_for_indexing.rs:97:13 |
61 | 84 | | |
62 | | -LL | assert!(v1.len() >= 12); |
63 | | - | ----------------------- help: provide the highest index that is indexed with: `assert!(v1.len() > 12)` |
64 | | -LL | assert!(v2.len() >= 15); |
65 | 85 | LL | let _ = v1[0] + v1[12]; |
66 | 86 | | ^^^^^ ^^^^^^ |
| 87 | + | |
| 88 | +help: provide the highest index that is indexed with |
| 89 | + | |
| 90 | +LL - assert!(v1.len() >= 12); |
| 91 | +LL + assert!(v1.len() > 12); |
| 92 | + | |
67 | 93 |
|
68 | 94 | error: indexing into a slice multiple times with an `assert` that does not cover the highest index |
69 | 95 | --> tests/ui/missing_asserts_for_indexing.rs:100:13 |
70 | 96 | | |
71 | | -LL | assert!(v2.len() >= 15); |
72 | | - | ----------------------- help: provide the highest index that is indexed with: `assert!(v2.len() > 15)` |
73 | | -... |
74 | 97 | LL | let _ = v2[5] + v2[15]; |
75 | 98 | | ^^^^^ ^^^^^^ |
| 99 | + | |
| 100 | +help: provide the highest index that is indexed with |
| 101 | + | |
| 102 | +LL - assert!(v2.len() >= 15); |
| 103 | +LL + assert!(v2.len() > 15); |
| 104 | + | |
76 | 105 |
|
77 | 106 | error: indexing into a slice multiple times with an `assert` that does not cover the highest index |
78 | 107 | --> tests/ui/missing_asserts_for_indexing.rs:106:13 |
79 | 108 | | |
80 | | -LL | assert!(v1.len() >= 12); |
81 | | - | ----------------------- help: provide the highest index that is indexed with: `assert!(v1.len() > 12)` |
82 | | -LL | assert!(v2.len() > 15); |
83 | 109 | LL | let _ = v1[0] + v1[12]; |
84 | 110 | | ^^^^^ ^^^^^^ |
| 111 | + | |
| 112 | +help: provide the highest index that is indexed with |
| 113 | + | |
| 114 | +LL - assert!(v1.len() >= 12); |
| 115 | +LL + assert!(v1.len() > 12); |
| 116 | + | |
85 | 117 |
|
86 | 118 | error: indexing into a slice multiple times with an `assert` that does not cover the highest index |
87 | 119 | --> tests/ui/missing_asserts_for_indexing.rs:131:13 |
88 | 120 | | |
89 | | -LL | assert!(v1.len() == 2); |
90 | | - | ---------------------- help: provide the highest index that is indexed with: `assert!(v1.len() == 3)` |
91 | | -... |
92 | 121 | LL | let _ = v1[0] + v1[1] + v1[2]; |
93 | 122 | | ^^^^^ ^^^^^ ^^^^^ |
| 123 | + | |
| 124 | +help: provide the highest index that is indexed with |
| 125 | + | |
| 126 | +LL - assert!(v1.len() == 2); |
| 127 | +LL + assert!(v1.len() == 3); |
| 128 | + | |
94 | 129 |
|
95 | 130 | error: indexing into a slice multiple times with an `assert` that does not cover the highest index |
96 | 131 | --> tests/ui/missing_asserts_for_indexing.rs:136:13 |
97 | 132 | | |
98 | | -LL | assert!(2 == v3.len()); |
99 | | - | ---------------------- help: provide the highest index that is indexed with: `assert!(v3.len() == 3)` |
100 | | -... |
101 | 133 | LL | let _ = v3[0] + v3[1] + v3[2]; |
102 | 134 | | ^^^^^ ^^^^^ ^^^^^ |
| 135 | + | |
| 136 | +help: provide the highest index that is indexed with |
| 137 | + | |
| 138 | +LL - assert!(2 == v3.len()); |
| 139 | +LL + assert!(v3.len() == 3); |
| 140 | + | |
103 | 141 |
|
104 | 142 | error: indexing into a slice multiple times with an `assert` that does not cover the highest index |
105 | 143 | --> tests/ui/missing_asserts_for_indexing.rs:158:13 |
106 | 144 | | |
107 | | -LL | assert_eq!(v1.len(), 2); |
108 | | - | ----------------------- help: provide the highest index that is indexed with: `assert_eq!(v1.len(), 3)` |
109 | | -... |
110 | 145 | LL | let _ = v1[0] + v1[1] + v1[2]; |
111 | 146 | | ^^^^^ ^^^^^ ^^^^^ |
| 147 | + | |
| 148 | +help: provide the highest index that is indexed with |
| 149 | + | |
| 150 | +LL - assert_eq!(v1.len(), 2); |
| 151 | +LL + assert_eq!(v1.len(), 3); |
| 152 | + | |
112 | 153 |
|
113 | 154 | error: indexing into a slice multiple times with an `assert` that does not cover the highest index |
114 | 155 | --> tests/ui/missing_asserts_for_indexing.rs:163:13 |
115 | 156 | | |
116 | | -LL | assert_eq!(2, v3.len()); |
117 | | - | ----------------------- help: provide the highest index that is indexed with: `assert_eq!(v3.len(), 3)` |
118 | | -... |
119 | 157 | LL | let _ = v3[0] + v3[1] + v3[2]; |
120 | 158 | | ^^^^^ ^^^^^ ^^^^^ |
| 159 | + | |
| 160 | +help: provide the highest index that is indexed with |
| 161 | + | |
| 162 | +LL - assert_eq!(2, v3.len()); |
| 163 | +LL + assert_eq!(v3.len(), 3); |
| 164 | + | |
121 | 165 |
|
122 | 166 | error: indexing into a slice multiple times with an `assert` that does not cover the highest index |
123 | 167 | --> tests/ui/missing_asserts_for_indexing.rs:172:17 |
124 | 168 | | |
125 | | -LL | assert_eq!(v.len(), 2); |
126 | | - | ---------------------- help: provide the highest index that is indexed with: `assert_eq!(v.len(), 3)` |
127 | 169 | LL | let _ = v[0] + v[1] + v[2]; |
128 | 170 | | ^^^^ ^^^^ ^^^^ |
| 171 | + | |
| 172 | +help: provide the highest index that is indexed with |
| 173 | + | |
| 174 | +LL - assert_eq!(v.len(), 2); |
| 175 | +LL + assert_eq!(v.len(), 3); |
| 176 | + | |
129 | 177 |
|
130 | 178 | error: indexing into a slice multiple times with an `assert` that does not cover the highest index |
131 | 179 | --> tests/ui/missing_asserts_for_indexing.rs:178:17 |
132 | 180 | | |
133 | | -LL | debug_assert_eq!(v.len(), 2); |
134 | | - | ---------------------------- help: provide the highest index that is indexed with: `debug_assert_eq!(v.len(), 3)` |
135 | 181 | LL | let _ = v[0] + v[1] + v[2]; |
136 | 182 | | ^^^^ ^^^^ ^^^^ |
| 183 | + | |
| 184 | +help: provide the highest index that is indexed with |
| 185 | + | |
| 186 | +LL - debug_assert_eq!(v.len(), 2); |
| 187 | +LL + debug_assert_eq!(v.len(), 3); |
| 188 | + | |
137 | 189 |
|
138 | 190 | error: aborting due to 15 previous errors |
139 | 191 |
|
0 commit comments