mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
33010ae7e6
This moves the `out_of_bounds_indexing` lint tests to their own directory.
23 lines
653 B
Rust
23 lines
653 B
Rust
#![warn(clippy::out_of_bounds_indexing)]
|
|
#![allow(clippy::no_effect, clippy::unnecessary_operation)]
|
|
|
|
fn main() {
|
|
let x = [1, 2, 3, 4];
|
|
|
|
&x[..=4];
|
|
&x[1..5];
|
|
&x[5..];
|
|
&x[..5];
|
|
&x[5..].iter().map(|x| 2 * x).collect::<Vec<i32>>();
|
|
&x[0..=4];
|
|
|
|
&x[4..]; // Ok, should not produce stderr.
|
|
&x[..4]; // Ok, should not produce stderr.
|
|
&x[..]; // Ok, should not produce stderr.
|
|
&x[1..]; // Ok, should not produce stderr.
|
|
&x[2..].iter().map(|x| 2 * x).collect::<Vec<i32>>(); // Ok, should not produce stderr.
|
|
|
|
&x[0..].get(..3); // Ok, should not produce stderr.
|
|
&x[0..3]; // Ok, should not produce stderr.
|
|
}
|