Skip to content

Commit

Permalink
Auto merge of #4626 - phansch:restore_test, r=<try>
Browse files Browse the repository at this point in the history
Revert "Remove tests that only ICE on CI"

This reverts commit 4318854.

If the integration tests pass, this closes #4607
  • Loading branch information
bors committed Oct 4, 2019
2 parents b824f02 + 8a780c8 commit ddf63cb
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/ui/out_of_bounds_indexing/empty_array.rs
Original file line number Diff line number Diff line change
@@ -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.
}
46 changes: 46 additions & 0 deletions tests/ui/out_of_bounds_indexing/empty_array.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ddf63cb

Please sign in to comment.