]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/out_of_bounds_indexing/simple.rs
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / src / tools / clippy / tests / ui / out_of_bounds_indexing / simple.rs
CommitLineData
f20569fa
XL
1#![warn(clippy::out_of_bounds_indexing)]
2#![allow(clippy::no_effect, clippy::unnecessary_operation, const_err)]
3
4fn main() {
5 let x = [1, 2, 3, 4];
6
7 &x[..=4];
8 &x[1..5];
9 &x[5..];
10 &x[..5];
11 &x[5..].iter().map(|x| 2 * x).collect::<Vec<i32>>();
12 &x[0..=4];
13
14 &x[4..]; // Ok, should not produce stderr.
15 &x[..4]; // Ok, should not produce stderr.
16 &x[..]; // Ok, should not produce stderr.
17 &x[1..]; // Ok, should not produce stderr.
18 &x[2..].iter().map(|x| 2 * x).collect::<Vec<i32>>(); // Ok, should not produce stderr.
19
20 &x[0..].get(..3); // Ok, should not produce stderr.
21 &x[0..3]; // Ok, should not produce stderr.
22}