From a6e6a6fd29616f4c4a60eb11923bc4e2b0097acd Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 5 Jun 2017 15:19:07 -0700 Subject: [PATCH] Add some more tests involving Offset/arith_offset and ZST pointers --- tests/run-pass/drop_empty_slice.rs | 9 +++++++++ tests/run-pass/iter_slice.rs | 12 ++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/run-pass/drop_empty_slice.rs create mode 100644 tests/run-pass/iter_slice.rs diff --git a/tests/run-pass/drop_empty_slice.rs b/tests/run-pass/drop_empty_slice.rs new file mode 100644 index 000000000000..25e7bc329db5 --- /dev/null +++ b/tests/run-pass/drop_empty_slice.rs @@ -0,0 +1,9 @@ +#![feature(box_syntax)] +// This disables the test completely: +// ignore-stage1 + +fn main() { + // With the nested Vec, this is calling Offset(Unique::empty(), 0). + let args : Vec> = Vec::new(); + let local = box args; +} diff --git a/tests/run-pass/iter_slice.rs b/tests/run-pass/iter_slice.rs new file mode 100644 index 000000000000..fd7229c3455e --- /dev/null +++ b/tests/run-pass/iter_slice.rs @@ -0,0 +1,12 @@ +fn main() { + for _ in Vec::::new().iter() { // this iterates over a Unique::empty() + panic!("We should never be here."); + } + + // Iterate over a ZST (uses arith_offset internally) + let mut count = 0; + for _ in &[(), (), ()] { + count += 1; + } + assert_eq!(count, 3); +}