From 3e655665b76e5771d74b6b2af9de1eaef5f43b60 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 19 Sep 2020 11:33:16 +0200 Subject: [PATCH 1/2] test VecDeque::iter_mut aliasing --- tests/run-pass/vecdeque.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/tests/run-pass/vecdeque.rs b/tests/run-pass/vecdeque.rs index 9c9909802e..34f32ee1d9 100644 --- a/tests/run-pass/vecdeque.rs +++ b/tests/run-pass/vecdeque.rs @@ -1,5 +1,17 @@ use std::collections::VecDeque; +fn test_all_refs<'a, T: 'a>(dummy: &mut T, iter: impl Iterator) { + // Gather all those references. + let mut refs: Vec<&mut T> = iter.collect(); + // Use them all. Twice, to be sure we got all interleavings. + for r in refs.iter_mut() { + std::mem::swap(dummy, r); + } + for r in refs { + std::mem::swap(dummy, r); + } +} + fn main() { let mut dst = VecDeque::new(); dst.push_front(Box::new(1)); @@ -18,6 +30,21 @@ fn main() { println!("{:?}", VecDeque::::new().iter()); for a in dst { - assert_eq!(*a, 2); + assert_eq!(*a, 2); } + + // # Aliasing tests. + let mut v = std::collections::VecDeque::new(); + v.push_back(1); + v.push_back(2); + + // Test `fold` bad aliasing. + let mut it = v.iter_mut(); + let ref0 = it.next().unwrap(); + let sum = it.fold(0, |x, y| x + *y); + assert_eq!(*ref0 + sum, 3); + + // Test general iterator aliasing. + v.push_front(0); + test_all_refs(&mut 0, v.iter_mut()); } From 63a0f04ed05af0b0822bfe000511e37489b71662 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 7 Oct 2020 09:05:18 +0200 Subject: [PATCH 2/2] rustup; bring back mir-opt-level 3 --- ci.sh | 3 +-- rust-version | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ci.sh b/ci.sh index a6daa80645..56a6f1228a 100755 --- a/ci.sh +++ b/ci.sh @@ -25,8 +25,7 @@ function run_tests { ./miri test --locked if ! [ -n "${MIRI_TEST_TARGET+exists}" ]; then # Only for host architecture: tests with MIR optimizations - #FIXME: Only testing opt level 1 due to . - MIRIFLAGS="-Z mir-opt-level=1" ./miri test --locked + MIRIFLAGS="-Z mir-opt-level=3" ./miri test --locked fi # "miri test" has built the sysroot for us, now this should pass without # any interactive questions. diff --git a/rust-version b/rust-version index b0644a3d73..79ba8eebc1 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -efbaa413061c2a6e52f06f00a60ee7830fcf3ea5 +c9ced8523bbb90561385aab305232f2167228a83