mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 23:20:39 +00:00
20 lines
561 B
Rust
20 lines
561 B
Rust
|
#![warn(clippy::out_of_bounds_indexing)]
|
||
|
#![allow(clippy::no_effect, clippy::unnecessary_operation)]
|
||
|
|
||
|
fn main() {
|
||
|
let empty: [i8; 0] = [];
|
||
|
empty[0]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays.
|
||
|
&empty[1..5];
|
||
|
&empty[0..=4];
|
||
|
&empty[..=4];
|
||
|
&empty[1..];
|
||
|
&empty[..4];
|
||
|
&empty[0..=0];
|
||
|
&empty[..=0];
|
||
|
|
||
|
&empty[0..]; // Ok, should not produce stderr.
|
||
|
&empty[0..0]; // Ok, should not produce stderr.
|
||
|
&empty[..0]; // Ok, should not produce stderr.
|
||
|
&empty[..]; // Ok, should not produce stderr.
|
||
|
}
|