2 #![warn(indexing_slicing)]
3 #![warn(out_of_bounds_indexing)]
4 #![allow(no_effect, unnecessary_operation)]
9 let index_from: usize = 2;
10 let index_to: usize = 3;
14 &x[index_from..index_to];
15 &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to].
20 &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10].
23 &x[5..].iter().map(|x| 2 * x).collect::<Vec<i32>>();
28 &x[4..]; // Ok, should not produce stderr.
29 &x[..4]; // Ok, should not produce stderr.
30 &x[..]; // Ok, should not produce stderr.
31 &x[1..]; // Ok, should not produce stderr.
32 &x[2..].iter().map(|x| 2 * x).collect::<Vec<i32>>(); // Ok, should not produce stderr.
33 &x[0..].get(..3); // Ok, should not produce stderr.
34 x[0]; // Ok, should not produce stderr.
35 x[3]; // Ok, should not produce stderr.
36 &x[0..3]; // Ok, should not produce stderr.
44 &y[..]; // Ok, should not produce stderr.
46 let empty: [i8; 0] = [];
56 &empty[0..]; // Ok, should not produce stderr.
57 &empty[0..0]; // Ok, should not produce stderr.
58 &empty[..0]; // Ok, should not produce stderr.
59 &empty[..]; // Ok, should not produce stderr.
66 &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100].
70 &v[..]; // Ok, should not produce stderr.