From 8a780c8a6a6b825ee509738ee009088744a3f629 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Fri, 4 Oct 2019 08:16:42 +0200 Subject: [PATCH] Revert "Remove tests that only ICE on CI" This reverts commit 4318854bfc8a3dc1755ca345a651112ea6bbded3. --- .../ui/out_of_bounds_indexing/empty_array.rs | 19 ++++++++ .../out_of_bounds_indexing/empty_array.stderr | 46 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tests/ui/out_of_bounds_indexing/empty_array.rs create mode 100644 tests/ui/out_of_bounds_indexing/empty_array.stderr diff --git a/tests/ui/out_of_bounds_indexing/empty_array.rs b/tests/ui/out_of_bounds_indexing/empty_array.rs new file mode 100644 index 000000000000..eebd5a6e2fbf --- /dev/null +++ b/tests/ui/out_of_bounds_indexing/empty_array.rs @@ -0,0 +1,19 @@ +#![warn(clippy::out_of_bounds_indexing)] +#![allow(clippy::no_effect, clippy::unnecessary_operation, const_err)] + +fn main() { + let empty: [i8; 0] = []; + empty[0]; + &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. +} diff --git a/tests/ui/out_of_bounds_indexing/empty_array.stderr b/tests/ui/out_of_bounds_indexing/empty_array.stderr new file mode 100644 index 000000000000..819c01f51739 --- /dev/null +++ b/tests/ui/out_of_bounds_indexing/empty_array.stderr @@ -0,0 +1,46 @@ +error: range is out of bounds + --> $DIR/empty_array.rs:7:12 + | +LL | &empty[1..5]; + | ^ + | + = note: `-D clippy::out-of-bounds-indexing` implied by `-D warnings` + +error: range is out of bounds + --> $DIR/empty_array.rs:8:16 + | +LL | &empty[0..=4]; + | ^ + +error: range is out of bounds + --> $DIR/empty_array.rs:9:15 + | +LL | &empty[..=4]; + | ^ + +error: range is out of bounds + --> $DIR/empty_array.rs:10:12 + | +LL | &empty[1..]; + | ^ + +error: range is out of bounds + --> $DIR/empty_array.rs:11:14 + | +LL | &empty[..4]; + | ^ + +error: range is out of bounds + --> $DIR/empty_array.rs:12:16 + | +LL | &empty[0..=0]; + | ^ + +error: range is out of bounds + --> $DIR/empty_array.rs:13:15 + | +LL | &empty[..=0]; + | ^ + +error: aborting due to 7 previous errors +