Skip to content

Commit e420e45

Browse files
authored
Rollup merge of #142215 - saethlin:mir-building-tests, r=cjgillot
Use -Zmir-opt-level=0 in tests for MIR building The mir-opt test suite currently defaults all tests in it to `-Zmir-opt-level=4`, so if a test is trying to test MIR _building_ not optimizations and it is in that directory, it _must_ override the default mir-opt-level.
2 parents 269d5b5 + 22cdf21 commit e420e45

26 files changed

+69
-47
lines changed

tests/mir-opt/building/async_await.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// related to `yield` are `&mut Context`, and its return type is `Poll`.
55

66
//@ edition:2018
7-
//@ compile-flags: -C panic=abort
7+
//@ compile-flags: -Zmir-opt-level=0 -C panic=abort
88

99
#![crate_type = "lib"]
1010

tests/mir-opt/building/dump_mir_cycle.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ compile-flags: -Zmir-opt-level=0
2+
13
#[derive(Debug)]
24
pub struct Thing {
35
pub next: &'static Thing,

tests/mir-opt/building/enum_cast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@ compile-flags: -Zmir-opt-level=0
12
// skip-filecheck
23
// EMIT_MIR enum_cast.foo.built.after.mir
34
// EMIT_MIR enum_cast.bar.built.after.mir

tests/mir-opt/building/eq_never_type.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@ compile-flags: -Zmir-opt-level=0
12
// skip-filecheck
23
#![feature(never_type)]
34
#![allow(unreachable_code)]

tests/mir-opt/building/index_array_and_slice.rs

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,42 @@
1-
//@ compile-flags: -C opt-level=0
1+
//@ compile-flags: -Zmir-opt-level=0 -C opt-level=0
22

33
// EMIT_MIR index_array_and_slice.index_array.built.after.mir
44
fn index_array(array: &[i32; 7], index: usize) -> &i32 {
55
// 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
89

910
// CHECK: bb1:
10-
// CHECK: _0 = &(*_1)[_2];
11+
// CHECK: _5 = &(*_1)[_3];
12+
// CHECK: _0 = &(*_5);
1113
&array[index]
1214
}
1315

1416
// EMIT_MIR index_array_and_slice.index_const_generic_array.built.after.mir
1517
fn index_const_generic_array<const N: usize>(array: &[i32; N], index: usize) -> &i32 {
1618
// 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
1922

2023
// CHECK: bb1:
21-
// CHECK: _0 = &(*_1)[_2];
24+
// CHECK: _5 = &(*_1)[_3];
25+
// CHECK: _0 = &(*_5);
2226
&array[index]
2327
}
2428

2529
// EMIT_MIR index_array_and_slice.index_slice.built.after.mir
2630
fn index_slice(slice: &[i32], index: usize) -> &i32 {
2731
// CHECK: bb0:
32+
// CHECK: _3 = copy _2;
2833
// 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,
3136

3237
// CHECK: bb1:
33-
// CHECK: _0 = &(*_1)[_2];
38+
// CHECK: _6 = &(*_1)[_3];
39+
// CHECK: _0 = &(*_6);
3440
&slice[index]
3541
}
3642

@@ -40,12 +46,15 @@ fn index_mut_slice(slice: &mut [i32], index: usize) -> &i32 {
4046
// This cannot `copy _1` in the *built* MIR, only in the *runtime* MIR.
4147

4248
// 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,
4654

4755
// CHECK: bb1:
48-
// CHECK: _0 = &(*_1)[_2];
56+
// CHECK: _7 = &(*_1)[_3];
57+
// CHECK: _0 = &(*_7);
4958
&slice[index]
5059
}
5160

@@ -54,13 +63,15 @@ struct WithSliceTail(f64, [i32]);
5463
// EMIT_MIR index_array_and_slice.index_custom.built.after.mir
5564
fn index_custom(custom: &WithSliceTail, index: usize) -> &i32 {
5665
// CHECK: bb0:
66+
// CHECK: _3 = copy _2;
5767
// 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,
6171

6272
// CHECK: bb1:
63-
// CHECK: _0 = &((*_1).1: [i32])[_2];
73+
// CHECK: _7 = &((*_1).1: [i32])[_3];
74+
// CHECK: _0 = &(*_7);
6475
&custom.1[index]
6576
}
6677

tests/mir-opt/building/issue_101867.main.built.after.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// MIR for `main` after built
22

33
| User Type Annotations
4-
| 0: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [] }, span: $DIR/issue_101867.rs:4:12: 4:22, inferred_ty: std::option::Option<u8>
5-
| 1: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [] }, span: $DIR/issue_101867.rs:4:12: 4:22, inferred_ty: std::option::Option<u8>
4+
| 0: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [] }, span: $DIR/issue_101867.rs:5:12: 5:22, inferred_ty: std::option::Option<u8>
5+
| 1: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [] }, span: $DIR/issue_101867.rs:5:12: 5:22, inferred_ty: std::option::Option<u8>
66
|
77
fn main() -> () {
88
let mut _0: ();

tests/mir-opt/building/issue_101867.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@ compile-flags: -Zmir-opt-level=0
12
// skip-filecheck
23
// EMIT_MIR issue_101867.main.built.after.mir
34
fn main() {

tests/mir-opt/building/issue_110508.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@ compile-flags: -Zmir-opt-level=0
12
// skip-filecheck
23
// EMIT_MIR issue_110508.{impl#0}-BAR.built.after.mir
34
// EMIT_MIR issue_110508.{impl#0}-SELF_BAR.built.after.mir

tests/mir-opt/building/issue_110508.{impl#0}-BAR.built.after.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// MIR for `<impl at $DIR/issue_110508.rs:9:1: 9:9>::BAR` after built
1+
// MIR for `<impl at $DIR/issue_110508.rs:10:1: 10:9>::BAR` after built
22

3-
const <impl at $DIR/issue_110508.rs:9:1: 9:9>::BAR: Foo = {
3+
const <impl at $DIR/issue_110508.rs:10:1: 10:9>::BAR: Foo = {
44
let mut _0: Foo;
55
let mut _1: ();
66

tests/mir-opt/building/issue_110508.{impl#0}-SELF_BAR.built.after.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// MIR for `<impl at $DIR/issue_110508.rs:9:1: 9:9>::SELF_BAR` after built
1+
// MIR for `<impl at $DIR/issue_110508.rs:10:1: 10:9>::SELF_BAR` after built
22

3-
const <impl at $DIR/issue_110508.rs:9:1: 9:9>::SELF_BAR: Foo = {
3+
const <impl at $DIR/issue_110508.rs:10:1: 10:9>::SELF_BAR: Foo = {
44
let mut _0: Foo;
55
let mut _1: ();
66

0 commit comments

Comments
 (0)