Skip to content

Commit ee30cc8

Browse files
committed
make some const prop tests unit-test
1 parent 36f4f4a commit ee30cc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+60
-38
lines changed

src/test/mir-opt/const_prop/aggregate.main.ConstProp.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
+ _1 = const 1_i32; // scope 0 at $DIR/aggregate.rs:+1:13: +1:28
2525
StorageDead(_2); // scope 0 at $DIR/aggregate.rs:+1:27: +1:28
2626
StorageDead(_3); // scope 0 at $DIR/aggregate.rs:+1:28: +1:29
27-
nop; // scope 0 at $DIR/aggregate.rs:+0:11: +2:2
27+
_0 = const (); // scope 0 at $DIR/aggregate.rs:+0:11: +2:2
2828
StorageDead(_1); // scope 0 at $DIR/aggregate.rs:+2:1: +2:2
2929
return; // scope 0 at $DIR/aggregate.rs:+2:2: +2:2
3030
}

src/test/mir-opt/const_prop/aggregate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// unit-test: ConstProp
12
// compile-flags: -O
23

34
// EMIT_MIR aggregate.main.ConstProp.diff

src/test/mir-opt/const_prop/array_index.main.ConstProp.32bit.diff

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,20 @@
1818
_2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; // scope 0 at $DIR/array_index.rs:+1:18: +1:30
1919
StorageLive(_3); // scope 0 at $DIR/array_index.rs:+1:31: +1:32
2020
_3 = const 2_usize; // scope 0 at $DIR/array_index.rs:+1:31: +1:32
21-
_4 = const 4_usize; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
21+
- _4 = Len(_2); // scope 0 at $DIR/array_index.rs:+1:18: +1:33
2222
- _5 = Lt(_3, _4); // scope 0 at $DIR/array_index.rs:+1:18: +1:33
2323
- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
24+
+ _4 = const 4_usize; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
2425
+ _5 = const true; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
25-
+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
26+
+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
2627
}
2728

2829
bb1: {
2930
- _1 = _2[_3]; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
3031
+ _1 = const 2_u32; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
3132
StorageDead(_3); // scope 0 at $DIR/array_index.rs:+1:33: +1:34
3233
StorageDead(_2); // scope 0 at $DIR/array_index.rs:+1:33: +1:34
33-
nop; // scope 0 at $DIR/array_index.rs:+0:11: +2:2
34+
_0 = const (); // scope 0 at $DIR/array_index.rs:+0:11: +2:2
3435
StorageDead(_1); // scope 0 at $DIR/array_index.rs:+2:1: +2:2
3536
return; // scope 0 at $DIR/array_index.rs:+2:2: +2:2
3637
}

src/test/mir-opt/const_prop/array_index.main.ConstProp.64bit.diff

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,20 @@
1818
_2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; // scope 0 at $DIR/array_index.rs:+1:18: +1:30
1919
StorageLive(_3); // scope 0 at $DIR/array_index.rs:+1:31: +1:32
2020
_3 = const 2_usize; // scope 0 at $DIR/array_index.rs:+1:31: +1:32
21-
_4 = const 4_usize; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
21+
- _4 = Len(_2); // scope 0 at $DIR/array_index.rs:+1:18: +1:33
2222
- _5 = Lt(_3, _4); // scope 0 at $DIR/array_index.rs:+1:18: +1:33
2323
- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
24+
+ _4 = const 4_usize; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
2425
+ _5 = const true; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
25-
+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
26+
+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
2627
}
2728

2829
bb1: {
2930
- _1 = _2[_3]; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
3031
+ _1 = const 2_u32; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
3132
StorageDead(_3); // scope 0 at $DIR/array_index.rs:+1:33: +1:34
3233
StorageDead(_2); // scope 0 at $DIR/array_index.rs:+1:33: +1:34
33-
nop; // scope 0 at $DIR/array_index.rs:+0:11: +2:2
34+
_0 = const (); // scope 0 at $DIR/array_index.rs:+0:11: +2:2
3435
StorageDead(_1); // scope 0 at $DIR/array_index.rs:+2:1: +2:2
3536
return; // scope 0 at $DIR/array_index.rs:+2:2: +2:2
3637
}

src/test/mir-opt/const_prop/array_index.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// unit-test: ConstProp
12
// EMIT_MIR_FOR_EACH_BIT_WIDTH
23

34
// EMIT_MIR array_index.main.ConstProp.diff

src/test/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.diff

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
StorageLive(_3); // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:18: +2:19
2525
- _3 = _1; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:18: +2:19
2626
- _4 = Eq(_3, const 0_i32); // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19
27-
- assert(!move _4, "attempt to divide `{}` by zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19
2827
+ _3 = const 0_i32; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:18: +2:19
2928
+ _4 = const true; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19
30-
+ assert(!const true, "attempt to divide `{}` by zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19
29+
assert(!move _4, "attempt to divide `{}` by zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19
3130
}
3231

3332
bb1: {
@@ -38,14 +37,13 @@
3837
+ _5 = const false; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19
3938
+ _6 = const false; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19
4039
+ _7 = const false; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19
41-
+ assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, const 0_i32) -> bb2; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19
40+
+ assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> bb2; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19
4241
}
4342

4443
bb2: {
45-
- _2 = Div(const 1_i32, move _3); // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19
46-
+ _2 = Div(const 1_i32, const 0_i32); // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19
44+
_2 = Div(const 1_i32, move _3); // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19
4745
StorageDead(_3); // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:18: +2:19
48-
nop; // scope 0 at $DIR/bad_op_div_by_zero.rs:+0:11: +3:2
46+
_0 = const (); // scope 0 at $DIR/bad_op_div_by_zero.rs:+0:11: +3:2
4947
StorageDead(_2); // scope 1 at $DIR/bad_op_div_by_zero.rs:+3:1: +3:2
5048
StorageDead(_1); // scope 0 at $DIR/bad_op_div_by_zero.rs:+3:1: +3:2
5149
return; // scope 0 at $DIR/bad_op_div_by_zero.rs:+3:2: +3:2

src/test/mir-opt/const_prop/bad_op_div_by_zero.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// unit-test: ConstProp
12
// EMIT_MIR bad_op_div_by_zero.main.ConstProp.diff
23
#[allow(unconditional_panic)]
34
fn main() {

src/test/mir-opt/const_prop/boolean_identities.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// unit-test: ConstProp
12
// compile-flags: -O -Zmir-opt-level=4
23

34
// EMIT_MIR boolean_identities.test.ConstProp.diff

src/test/mir-opt/const_prop/boxes.main.ConstProp.diff

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@
2626
StorageLive(_3); // scope 0 at $DIR/boxes.rs:+1:14: +1:22
2727
- _4 = SizeOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +1:22
2828
- _5 = AlignOf(i32); // scope 2 at $DIR/boxes.rs:+1:14: +1:22
29-
- _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> bb1; // scope 2 at $DIR/boxes.rs:+1:14: +1:22
3029
+ _4 = const 4_usize; // scope 2 at $DIR/boxes.rs:+1:14: +1:22
3130
+ _5 = const 4_usize; // scope 2 at $DIR/boxes.rs:+1:14: +1:22
32-
+ _6 = alloc::alloc::exchange_malloc(const 4_usize, const 4_usize) -> bb1; // scope 2 at $DIR/boxes.rs:+1:14: +1:22
31+
_6 = alloc::alloc::exchange_malloc(move _4, move _5) -> bb1; // scope 2 at $DIR/boxes.rs:+1:14: +1:22
3332
// mir::Constant
34-
// + span: $DIR/boxes.rs:12:14: 12:22
33+
// + span: $DIR/boxes.rs:13:14: 13:22
3534
// + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
3635
}
3736

@@ -55,7 +54,7 @@
5554

5655
bb2: {
5756
StorageDead(_3); // scope 0 at $DIR/boxes.rs:+1:26: +1:27
58-
nop; // scope 0 at $DIR/boxes.rs:+0:11: +2:2
57+
_0 = const (); // scope 0 at $DIR/boxes.rs:+0:11: +2:2
5958
StorageDead(_1); // scope 0 at $DIR/boxes.rs:+2:1: +2:2
6059
return; // scope 0 at $DIR/boxes.rs:+2:2: +2:2
6160
}

src/test/mir-opt/const_prop/boxes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// unit-test: ConstProp
12
// compile-flags: -O
23
// ignore-emscripten compiled with panic=abort by default
34
// ignore-wasm32

0 commit comments

Comments
 (0)