1
- //@ compile-flags: -C opt-level=0
1
+ //@ compile-flags: -Zmir-opt-level=0 - C opt-level=0
2
2
3
3
// EMIT_MIR index_array_and_slice.index_array.built.after.mir
4
4
fn index_array ( array : & [ i32 ; 7 ] , index : usize ) -> & i32 {
5
5
// CHECK: bb0:
6
- // CHECK: [[LT:_.+]] = Lt(copy _2, const 7_usize);
7
- // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", const 7_usize, copy _2) -> [success: bb1, unwind
6
+ // CHECK: _3 = copy _2;
7
+ // CHECK: [[LT:_.+]] = Lt(copy _3, const 7_usize);
8
+ // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", const 7_usize, copy _3) -> [success: bb1, unwind
8
9
9
10
// CHECK: bb1:
10
- // CHECK: _0 = &(*_1)[_2];
11
+ // CHECK: _5 = &(*_1)[_3];
12
+ // CHECK: _0 = &(*_5);
11
13
& array[ index]
12
14
}
13
15
14
16
// EMIT_MIR index_array_and_slice.index_const_generic_array.built.after.mir
15
17
fn index_const_generic_array < const N : usize > ( array : & [ i32 ; N ] , index : usize ) -> & i32 {
16
18
// CHECK: bb0:
17
- // CHECK: [[LT:_.+]] = Lt(copy _2, const N);
18
- // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", const N, copy _2) -> [success: bb1, unwind
19
+ // CHECK: _3 = copy _2;
20
+ // CHECK: [[LT:_.+]] = Lt(copy _3, const N);
21
+ // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", const N, copy _3) -> [success: bb1, unwind
19
22
20
23
// CHECK: bb1:
21
- // CHECK: _0 = &(*_1)[_2];
24
+ // CHECK: _5 = &(*_1)[_3];
25
+ // CHECK: _0 = &(*_5);
22
26
& array[ index]
23
27
}
24
28
25
29
// EMIT_MIR index_array_and_slice.index_slice.built.after.mir
26
30
fn index_slice ( slice : & [ i32 ] , index : usize ) -> & i32 {
27
31
// CHECK: bb0:
32
+ // CHECK: _3 = copy _2;
28
33
// CHECK: [[LEN:_.+]] = PtrMetadata(copy _1);
29
- // CHECK: [[LT:_.+]] = Lt(copy _2 , copy [[LEN]]);
30
- // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", move [[LEN]], copy _2 ) -> [success: bb1,
34
+ // CHECK: [[LT:_.+]] = Lt(copy _3 , copy [[LEN]]);
35
+ // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", move [[LEN]], copy _3 ) -> [success: bb1,
31
36
32
37
// CHECK: bb1:
33
- // CHECK: _0 = &(*_1)[_2];
38
+ // CHECK: _6 = &(*_1)[_3];
39
+ // CHECK: _0 = &(*_6);
34
40
& slice[ index]
35
41
}
36
42
@@ -40,12 +46,15 @@ fn index_mut_slice(slice: &mut [i32], index: usize) -> &i32 {
40
46
// This cannot `copy _1` in the *built* MIR, only in the *runtime* MIR.
41
47
42
48
// CHECK: bb0:
43
- // CHECK: [[LEN:_.+]] = PtrMetadata(copy _1);
44
- // CHECK: [[LT:_.+]] = Lt(copy _2, copy [[LEN]]);
45
- // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", move [[LEN]], copy _2) -> [success: bb1,
49
+ // CHECK: _3 = copy _2;
50
+ // CHECK: _4 = &raw const (fake) (*_1);
51
+ // CHECK: [[LEN:_.+]] = PtrMetadata(move _4);
52
+ // CHECK: [[LT:_.+]] = Lt(copy _3, copy [[LEN]]);
53
+ // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", move [[LEN]], copy _3) -> [success: bb1,
46
54
47
55
// CHECK: bb1:
48
- // CHECK: _0 = &(*_1)[_2];
56
+ // CHECK: _7 = &(*_1)[_3];
57
+ // CHECK: _0 = &(*_7);
49
58
& slice[ index]
50
59
}
51
60
@@ -54,13 +63,15 @@ struct WithSliceTail(f64, [i32]);
54
63
// EMIT_MIR index_array_and_slice.index_custom.built.after.mir
55
64
fn index_custom ( custom : & WithSliceTail , index : usize ) -> & i32 {
56
65
// CHECK: bb0:
66
+ // CHECK: _3 = copy _2;
57
67
// CHECK: [[PTR:_.+]] = &raw const (fake) ((*_1).1: [i32]);
58
- // CHECK: [[LEN:_.+]] = PtrMetadata(copy [[PTR]]);
59
- // CHECK: [[LT:_.+]] = Lt(copy _2 , copy [[LEN]]);
60
- // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", move [[LEN]], copy _2 ) -> [success: bb1,
68
+ // CHECK: [[LEN:_.+]] = PtrMetadata(move [[PTR]]);
69
+ // CHECK: [[LT:_.+]] = Lt(copy _3 , copy [[LEN]]);
70
+ // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", move [[LEN]], copy _3 ) -> [success: bb1,
61
71
62
72
// CHECK: bb1:
63
- // CHECK: _0 = &((*_1).1: [i32])[_2];
73
+ // CHECK: _7 = &((*_1).1: [i32])[_3];
74
+ // CHECK: _0 = &(*_7);
64
75
& custom. 1 [ index]
65
76
}
66
77
0 commit comments