Skip to content

Commit c6dbe5c

Browse files
committed
use references so that potential aliasing bugs are triggered during regression test
1 parent b8aba11 commit c6dbe5c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/run-pass/slices.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// compile-flags: -Zmiri-track-raw-pointers
12
#![feature(new_uninit)]
23
#![feature(slice_as_chunks)]
34
#![feature(slice_partition_dedup)]
@@ -220,13 +221,23 @@ fn test_for_invalidated_pointers() {
220221

221222
// Calls `fn as_chunks_unchecked_mut` internally (requires unstable `#![feature(slice_as_chunks)]`):
222223
assert_eq!(2, buffer.as_chunks_mut::<32>().0.len());
224+
for chunk in buffer.as_chunks_mut::<32>().0 {
225+
for elem in chunk {
226+
*elem += 1;
227+
}
228+
}
223229

224230
// Calls `fn split_at_mut_unchecked` internally:
225231
let split_mut = buffer.split_at_mut(32);
226232
assert_eq!(split_mut.0, split_mut.1);
227233

228234
// Calls `fn partition_dedup_by` internally (requires unstable `#![feature(slice_partition_dedup)]`):
229-
assert_eq!(1, buffer.partition_dedup().0.len());
235+
let partition_dedup = buffer.partition_dedup();
236+
assert_eq!(1, partition_dedup.0.len());
237+
partition_dedup.0[0] += 1;
238+
for elem in partition_dedup.1 {
239+
*elem += 1;
240+
}
230241

231242
buffer.rotate_left(8);
232243
buffer.rotate_right(16);

0 commit comments

Comments
 (0)