File tree 3 files changed +30
-4
lines changed
3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -25,8 +25,7 @@ function run_tests {
25
25
./miri test --locked
26
26
if ! [ -n " ${MIRI_TEST_TARGET+exists} " ]; then
27
27
# Only for host architecture: tests with MIR optimizations
28
- # FIXME: Only testing opt level 1 due to <https://github.com/rust-lang/rust/issues/77564>.
29
- MIRIFLAGS=" -Z mir-opt-level=1" ./miri test --locked
28
+ MIRIFLAGS=" -Z mir-opt-level=3" ./miri test --locked
30
29
fi
31
30
# "miri test" has built the sysroot for us, now this should pass without
32
31
# any interactive questions.
Original file line number Diff line number Diff line change 1
- efbaa413061c2a6e52f06f00a60ee7830fcf3ea5
1
+ c9ced8523bbb90561385aab305232f2167228a83
Original file line number Diff line number Diff line change 1
1
use std:: collections:: VecDeque ;
2
2
3
+ fn test_all_refs < ' a , T : ' a > ( dummy : & mut T , iter : impl Iterator < Item = & ' a mut T > ) {
4
+ // Gather all those references.
5
+ let mut refs: Vec < & mut T > = iter. collect ( ) ;
6
+ // Use them all. Twice, to be sure we got all interleavings.
7
+ for r in refs. iter_mut ( ) {
8
+ std:: mem:: swap ( dummy, r) ;
9
+ }
10
+ for r in refs {
11
+ std:: mem:: swap ( dummy, r) ;
12
+ }
13
+ }
14
+
3
15
fn main ( ) {
4
16
let mut dst = VecDeque :: new ( ) ;
5
17
dst. push_front ( Box :: new ( 1 ) ) ;
@@ -18,6 +30,21 @@ fn main() {
18
30
println ! ( "{:?}" , VecDeque :: <u32 >:: new( ) . iter( ) ) ;
19
31
20
32
for a in dst {
21
- assert_eq ! ( * a, 2 ) ;
33
+ assert_eq ! ( * a, 2 ) ;
22
34
}
35
+
36
+ // # Aliasing tests.
37
+ let mut v = std:: collections:: VecDeque :: new ( ) ;
38
+ v. push_back ( 1 ) ;
39
+ v. push_back ( 2 ) ;
40
+
41
+ // Test `fold` bad aliasing.
42
+ let mut it = v. iter_mut ( ) ;
43
+ let ref0 = it. next ( ) . unwrap ( ) ;
44
+ let sum = it. fold ( 0 , |x, y| x + * y) ;
45
+ assert_eq ! ( * ref0 + sum, 3 ) ;
46
+
47
+ // Test general iterator aliasing.
48
+ v. push_front ( 0 ) ;
49
+ test_all_refs ( & mut 0 , v. iter_mut ( ) ) ;
23
50
}
You can’t perform that action at this time.
0 commit comments