Skip to content

Commit

Permalink
regression test for reverse() unsoundness
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Mar 22, 2022
1 parent 694846f commit 951ac65
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/run-pass/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ fn swap_remove() {
vec.swap_remove(1);
}

fn reverse() {
#[repr(align(2))]
#[derive(Debug)]
struct Foo(u8);

let mut v: Vec<_> = (0..50).map(Foo).collect();
v.reverse();
assert!(v[0].0 == 49);
}

fn main() {
assert_eq!(vec_reallocate().len(), 5);

Expand Down Expand Up @@ -176,4 +186,5 @@ fn main() {
sort();
swap();
swap_remove();
reverse();
}

0 comments on commit 951ac65

Please sign in to comment.