Skip to content

Commit f9d6cc5

Browse files
authored
Rollup merge of #100086 - JakobDegen:better-tests, r=wesleyweiser
Add more `// unit-test`s to MIR opt tests I only changed things which are hopefully completely uninteresting. I plan to submit more PRs that cover more files, but those cases will need some more complicated (and hence possibly controversial) changes, so I'll try and submit those in reasonably sized batches. r? rust-lang/wg-mir-opt
2 parents 6b5ec41 + 7a1bfc0 commit f9d6cc5

36 files changed

+167
-186
lines changed

src/test/mir-opt/bool_compare.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// unit-test: InstCombine
2+
13
// EMIT_MIR bool_compare.opt1.InstCombine.diff
24
fn opt1(x: bool) -> u32 {
35
if x != true { 0 } else { 1 }

src/test/mir-opt/combine_array_len.norm2.InstCombine.64bit.diff

-77
This file was deleted.

src/test/mir-opt/combine_array_len.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// EMIT_MIR_FOR_EACH_BIT_WIDTH
1+
// unit-test: InstCombine
22
// EMIT_MIR combine_array_len.norm2.InstCombine.diff
33

44
fn norm2(x: [f32; 2]) -> f32 {

src/test/mir-opt/const_goto.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// unit-test: ConstGoto
2+
13
pub enum Foo {
24
A,
35
B,

src/test/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
bb0: {
1818
StorageLive(_1); // scope 0 at $DIR/const_goto_storage.rs:+1:9: +1:12
1919
- StorageLive(_2); // scope 0 at $DIR/const_goto_storage.rs:+1:21: +1:23
20-
- nop; // scope 0 at $DIR/const_goto_storage.rs:+1:21: +1:23
20+
- Deinit(_2); // scope 0 at $DIR/const_goto_storage.rs:+1:21: +1:23
2121
- StorageLive(_3); // scope 0 at $DIR/const_goto_storage.rs:+2:15: +6:10
2222
- StorageLive(_4); // scope 0 at $DIR/const_goto_storage.rs:+2:18: +2:76
2323
- StorageLive(_5); // scope 0 at $DIR/const_goto_storage.rs:+2:21: +2:52

src/test/mir-opt/const_goto_storage.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// unit-test: ConstGoto
2+
13
// EMIT_MIR const_goto_storage.match_nested_if.ConstGoto.diff
24
fn match_nested_if() -> bool {
35
let val = match () {

src/test/mir-opt/deaggregator_test.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// unit-test: Deaggregator
2+
13
struct Baz {
24
x: usize,
35
y: f32,

src/test/mir-opt/deaggregator_test_enum.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// unit-test: Deaggregator
2+
13
enum Baz {
24
Empty,
35
Foo { x: usize },

src/test/mir-opt/deaggregator_test_enum_2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// unit-test: Deaggregator
12
// Test that deaggregate fires in more than one basic block
23

34
enum Foo {

src/test/mir-opt/deaggregator_test_multiple.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// unit-test: Deaggregator
12
// Test that deaggregate fires more than once per block
23

34
enum Foo {

src/test/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff

+41-48
Original file line numberDiff line numberDiff line change
@@ -7,101 +7,94 @@
77
let mut _2: &[u8]; // in scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23
88
let mut _3: &str; // in scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23
99
let mut _4: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
10-
let mut _5: bool; // in scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
11-
let mut _6: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
12-
let mut _7: bool; // in scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
13-
scope 1 (inlined core::str::<impl str>::as_bytes) { // at $DIR/deduplicate_blocks.rs:3:11: 3:23
14-
debug self => _3; // in scope 1 at $SRC_DIR/core/src/str/mod.rs:LL:COL
15-
let mut _8: &str; // in scope 1 at $SRC_DIR/core/src/str/mod.rs:LL:COL
16-
scope 2 {
17-
}
18-
}
10+
let mut _5: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
11+
let mut _6: bool; // in scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
12+
let mut _7: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
13+
let mut _8: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
14+
let mut _9: bool; // in scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
1915

2016
bb0: {
2117
StorageLive(_2); // scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23
2218
StorageLive(_3); // scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23
23-
_3 = _1; // scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23
24-
StorageLive(_8); // scope 2 at $SRC_DIR/core/src/str/mod.rs:LL:COL
25-
_8 = _3; // scope 2 at $SRC_DIR/core/src/str/mod.rs:LL:COL
26-
- _2 = transmute::<&str, &[u8]>(move _8) -> bb14; // scope 2 at $SRC_DIR/core/src/str/mod.rs:LL:COL
27-
+ _2 = transmute::<&str, &[u8]>(move _8) -> bb12; // scope 2 at $SRC_DIR/core/src/str/mod.rs:LL:COL
19+
_3 = &(*_1); // scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23
20+
_2 = core::str::<impl str>::as_bytes(move _3) -> bb1; // scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23
2821
// mir::Constant
29-
// + span: $SRC_DIR/core/src/str/mod.rs:LL:COL
30-
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&str) -> &[u8] {transmute::<&str, &[u8]>}, val: Value(<ZST>) }
22+
// + span: $DIR/deduplicate_blocks.rs:5:13: 5:21
23+
// + literal: Const { ty: for<'r> fn(&'r str) -> &'r [u8] {core::str::<impl str>::as_bytes}, val: Value(<ZST>) }
3124
}
3225

3326
bb1: {
34-
switchInt((*_2)[0 of 4]) -> [47_u8: bb2, otherwise: bb5]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
27+
StorageDead(_3); // scope 0 at $DIR/deduplicate_blocks.rs:+1:22: +1:23
28+
_7 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
29+
_8 = const 4_usize; // scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
30+
_9 = Ge(move _7, move _8); // scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
31+
switchInt(move _9) -> [false: bb6, otherwise: bb2]; // scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
3532
}
3633

3734
bb2: {
38-
switchInt((*_2)[1 of 4]) -> [47_u8: bb3, otherwise: bb5]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
35+
switchInt((*_2)[0 of 4]) -> [47_u8: bb3, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
3936
}
4037

4138
bb3: {
42-
switchInt((*_2)[2 of 4]) -> [47_u8: bb4, otherwise: bb5]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
39+
switchInt((*_2)[1 of 4]) -> [47_u8: bb4, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
4340
}
4441

4542
bb4: {
46-
- switchInt((*_2)[3 of 4]) -> [47_u8: bb10, otherwise: bb5]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
47-
+ switchInt((*_2)[3 of 4]) -> [47_u8: bb9, otherwise: bb5]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
43+
switchInt((*_2)[2 of 4]) -> [47_u8: bb5, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
4844
}
4945

5046
bb5: {
51-
_4 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
52-
_5 = Ge(move _4, const 3_usize); // scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
53-
switchInt(move _5) -> [false: bb9, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
47+
- switchInt((*_2)[3 of 4]) -> [47_u8: bb11, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
48+
+ switchInt((*_2)[3 of 4]) -> [47_u8: bb10, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
5449
}
5550

5651
bb6: {
57-
switchInt((*_2)[0 of 3]) -> [47_u8: bb7, otherwise: bb9]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
52+
_4 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
53+
_5 = const 3_usize; // scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
54+
_6 = Ge(move _4, move _5); // scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
55+
switchInt(move _6) -> [false: bb10, otherwise: bb7]; // scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
5856
}
5957

6058
bb7: {
61-
switchInt((*_2)[1 of 3]) -> [47_u8: bb8, otherwise: bb9]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
59+
switchInt((*_2)[0 of 3]) -> [47_u8: bb8, otherwise: bb10]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
6260
}
6361

6462
bb8: {
65-
- switchInt((*_2)[2 of 3]) -> [47_u8: bb11, 33_u8: bb12, otherwise: bb9]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
66-
+ switchInt((*_2)[2 of 3]) -> [47_u8: bb10, 33_u8: bb10, otherwise: bb9]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
63+
switchInt((*_2)[1 of 3]) -> [47_u8: bb9, otherwise: bb10]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
6764
}
6865

6966
bb9: {
67+
- switchInt((*_2)[2 of 3]) -> [47_u8: bb12, 33_u8: bb13, otherwise: bb10]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
68+
+ switchInt((*_2)[2 of 3]) -> [47_u8: bb11, 33_u8: bb11, otherwise: bb10]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
69+
}
70+
71+
bb10: {
7072
- _0 = const false; // scope 0 at $DIR/deduplicate_blocks.rs:+5:14: +5:19
71-
- goto -> bb13; // scope 0 at $DIR/deduplicate_blocks.rs:+5:14: +5:19
73+
- goto -> bb14; // scope 0 at $DIR/deduplicate_blocks.rs:+5:14: +5:19
7274
- }
7375
-
74-
- bb10: {
76+
- bb11: {
7577
_0 = const false; // scope 0 at $DIR/deduplicate_blocks.rs:+2:41: +2:46
76-
- goto -> bb13; // scope 0 at $DIR/deduplicate_blocks.rs:+2:41: +2:46
77-
+ goto -> bb11; // scope 0 at $DIR/deduplicate_blocks.rs:+2:41: +2:46
78+
- goto -> bb14; // scope 0 at $DIR/deduplicate_blocks.rs:+2:41: +2:46
79+
+ goto -> bb12; // scope 0 at $DIR/deduplicate_blocks.rs:+2:41: +2:46
7880
}
7981

80-
- bb11: {
82+
- bb12: {
8183
- _0 = const true; // scope 0 at $DIR/deduplicate_blocks.rs:+3:35: +3:39
82-
- goto -> bb13; // scope 0 at $DIR/deduplicate_blocks.rs:+3:35: +3:39
84+
- goto -> bb14; // scope 0 at $DIR/deduplicate_blocks.rs:+3:35: +3:39
8385
- }
8486
-
85-
- bb12: {
86-
+ bb10: {
87-
_0 = const true; // scope 0 at $DIR/deduplicate_blocks.rs:+4:35: +4:39
88-
- goto -> bb13; // scope 0 at $DIR/deduplicate_blocks.rs:+4:35: +4:39
89-
+ goto -> bb11; // scope 0 at $DIR/deduplicate_blocks.rs:+4:35: +4:39
90-
}
91-
9287
- bb13: {
9388
+ bb11: {
94-
StorageDead(_2); // scope 0 at $DIR/deduplicate_blocks.rs:+7:1: +7:2
95-
return; // scope 0 at $DIR/deduplicate_blocks.rs:+7:2: +7:2
89+
_0 = const true; // scope 0 at $DIR/deduplicate_blocks.rs:+4:35: +4:39
90+
- goto -> bb14; // scope 0 at $DIR/deduplicate_blocks.rs:+4:35: +4:39
91+
+ goto -> bb12; // scope 0 at $DIR/deduplicate_blocks.rs:+4:35: +4:39
9692
}
9793

9894
- bb14: {
9995
+ bb12: {
100-
StorageDead(_8); // scope 2 at $SRC_DIR/core/src/str/mod.rs:LL:COL
101-
StorageDead(_3); // scope 0 at $DIR/deduplicate_blocks.rs:+1:22: +1:23
102-
_6 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
103-
_7 = Ge(move _6, const 4_usize); // scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
104-
switchInt(move _7) -> [false: bb5, otherwise: bb1]; // scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
96+
StorageDead(_2); // scope 0 at $DIR/deduplicate_blocks.rs:+7:1: +7:2
97+
return; // scope 0 at $DIR/deduplicate_blocks.rs:+7:2: +7:2
10598
}
10699
}
107100

src/test/mir-opt/deduplicate_blocks.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// unit-test: DeduplicateBlocks
2+
13
// EMIT_MIR deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff
24
pub const fn is_line_doc_comment_2(s: &str) -> bool {
35
match s.as_bytes() {

src/test/mir-opt/derefer_complex_case.main.Derefer.diff

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
StorageLive(_2); // scope 0 at $DIR/derefer_complex_case.rs:+1:17: +1:26
3131
_14 = const main::promoted[0]; // scope 0 at $DIR/derefer_complex_case.rs:+1:17: +1:26
3232
// mir::Constant
33-
// + span: $DIR/derefer_complex_case.rs:5:17: 5:26
33+
// + span: $DIR/derefer_complex_case.rs:6:17: 6:26
3434
// + literal: Const { ty: &[i32; 2], val: Unevaluated(main, [], Some(promoted[0])) }
3535
_2 = &(*_14); // scope 0 at $DIR/derefer_complex_case.rs:+1:17: +1:26
3636
_1 = <&[i32; 2] as IntoIterator>::into_iter(move _2) -> bb1; // scope 0 at $DIR/derefer_complex_case.rs:+1:17: +1:26
3737
// mir::Constant
38-
// + span: $DIR/derefer_complex_case.rs:5:17: 5:26
38+
// + span: $DIR/derefer_complex_case.rs:6:17: 6:26
3939
// + literal: Const { ty: fn(&[i32; 2]) -> <&[i32; 2] as IntoIterator>::IntoIter {<&[i32; 2] as IntoIterator>::into_iter}, val: Value(<ZST>) }
4040
}
4141

@@ -55,7 +55,7 @@
5555
_8 = &mut (*_9); // scope 1 at $DIR/derefer_complex_case.rs:+1:17: +1:26
5656
_7 = <std::slice::Iter<i32> as Iterator>::next(move _8) -> bb3; // scope 1 at $DIR/derefer_complex_case.rs:+1:17: +1:26
5757
// mir::Constant
58-
// + span: $DIR/derefer_complex_case.rs:5:17: 5:26
58+
// + span: $DIR/derefer_complex_case.rs:6:17: 6:26
5959
// + literal: Const { ty: for<'r> fn(&'r mut std::slice::Iter<i32>) -> Option<<std::slice::Iter<i32> as Iterator>::Item> {<std::slice::Iter<i32> as Iterator>::next}, val: Value(<ZST>) }
6060
}
6161

@@ -76,7 +76,7 @@
7676
_13 = _12; // scope 2 at $DIR/derefer_complex_case.rs:+1:34: +1:37
7777
_6 = std::mem::drop::<i32>(move _13) -> bb7; // scope 2 at $DIR/derefer_complex_case.rs:+1:29: +1:38
7878
// mir::Constant
79-
// + span: $DIR/derefer_complex_case.rs:5:29: 5:33
79+
// + span: $DIR/derefer_complex_case.rs:6:29: 6:33
8080
// + literal: Const { ty: fn(i32) {std::mem::drop::<i32>}, val: Value(<ZST>) }
8181
}
8282

src/test/mir-opt/derefer_complex_case.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// unit-test: Derefer
12
// EMIT_MIR derefer_complex_case.main.Derefer.diff
23
// ignore-wasm32
34

0 commit comments

Comments
 (0)