Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f64c307

Browse files
committedJun 29, 2024·
Run SingleUseConsts before DeadStoreElimination::Initial
1 parent 7b8c23d commit f64c307

File tree

28 files changed

+150
-153
lines changed

28 files changed

+150
-153
lines changed
 

‎compiler/rustc_mir_transform/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,11 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
593593
&multiple_return_terminators::MultipleReturnTerminators,
594594
&instsimplify::InstSimplify,
595595
&simplify::SimplifyLocals::BeforeConstProp,
596-
&dead_store_elimination::DeadStoreElimination::Initial,
597596
&gvn::GVN,
598597
&simplify::SimplifyLocals::AfterGVN,
599598
&dataflow_const_prop::DataflowConstProp,
600599
&single_use_consts::SingleUseConsts,
600+
&dead_store_elimination::DeadStoreElimination::Initial,
601601
&o1(simplify_branches::SimplifyConstCondition::AfterConstProp),
602602
&jump_threading::JumpThreading,
603603
&early_otherwise_branch::EarlyOtherwiseBranch,

‎tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
StorageLive(_3);
2727
StorageLive(_4);
2828
_4 = [_1, _1, _1];
29-
_3 = &_4;
30-
_2 = move _3 as &[T] (PointerCoercion(Unsize));
29+
nop;
30+
nop;
3131
StorageDead(_3);
3232
nop;
3333
nop;
@@ -40,8 +40,11 @@
4040

4141
bb2: {
4242
StorageLive(_7);
43+
nop;
4344
StorageLive(_8);
45+
nop;
4446
StorageLive(_9);
47+
nop;
4548
StorageDead(_9);
4649
StorageDead(_8);
4750
StorageDead(_7);

‎tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
StorageLive(_3);
2727
StorageLive(_4);
2828
_4 = [_1, _1, _1];
29-
_3 = &_4;
30-
_2 = move _3 as &[T] (PointerCoercion(Unsize));
29+
nop;
30+
nop;
3131
StorageDead(_3);
3232
nop;
3333
nop;
@@ -40,8 +40,11 @@
4040

4141
bb2: {
4242
StorageLive(_7);
43+
nop;
4344
StorageLive(_8);
45+
nop;
4446
StorageLive(_9);
47+
nop;
4548
StorageDead(_9);
4649
StorageDead(_8);
4750
StorageDead(_7);

‎tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ fn <impl at $DIR/derived_ord.rs:6:10: 6:20>::partial_cmp(_1: &MultiField, _2: &M
66
let mut _0: std::option::Option<std::cmp::Ordering>;
77
let mut _6: std::option::Option<std::cmp::Ordering>;
88
let mut _7: i8;
9+
let _11: std::option::Option<std::cmp::Ordering>;
910
scope 1 {
10-
debug cmp => _6;
11+
debug cmp => _11;
1112
}
1213
scope 2 (inlined std::cmp::impls::<impl PartialOrd for char>::partial_cmp) {
1314
let mut _3: char;
@@ -48,7 +49,9 @@ fn <impl at $DIR/derived_ord.rs:6:10: 6:20>::partial_cmp(_1: &MultiField, _2: &M
4849
}
4950

5051
bb2: {
52+
StorageLive(_11);
5153
_0 = _6;
54+
StorageDead(_11);
5255
goto -> bb3;
5356
}
5457

‎tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,19 @@
100100
}
101101

102102
bb6: {
103-
nop;
103+
_5 = move ((_6 as Ok).0: std::ptr::NonNull<[u8]>);
104104
StorageDead(_12);
105105
StorageDead(_6);
106-
StorageLive(_17);
107-
nop;
108-
nop;
109-
StorageDead(_17);
106+
- StorageLive(_17);
107+
+ nop;
108+
_17 = (_5.0: *const [u8]);
109+
- _4 = move _17 as *mut [u8] (PtrToPtr);
110+
- StorageDead(_17);
111+
+ _4 = _17 as *mut [u8] (PtrToPtr);
112+
+ nop;
110113
StorageDead(_5);
111-
nop;
114+
- _3 = move _4 as *mut u8 (PtrToPtr);
115+
+ _3 = _17 as *mut u8 (PtrToPtr);
112116
StorageDead(_4);
113117
StorageDead(_3);
114118
- StorageDead(_1);

‎tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@
4545

4646
bb1: {
4747
StorageDead(_6);
48-
StorageLive(_12);
49-
nop;
50-
nop;
51-
StorageDead(_12);
48+
- StorageLive(_12);
49+
+ nop;
50+
_12 = (_5.0: *const [u8]);
51+
- _4 = move _12 as *mut [u8] (PtrToPtr);
52+
- StorageDead(_12);
53+
+ _4 = _12 as *mut [u8] (PtrToPtr);
54+
+ nop;
5255
StorageDead(_5);
53-
nop;
56+
- _3 = move _4 as *mut u8 (PtrToPtr);
57+
+ _3 = _12 as *mut u8 (PtrToPtr);
5458
StorageDead(_4);
5559
StorageDead(_3);
5660
- StorageDead(_1);

‎tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,19 @@
100100
}
101101

102102
bb6: {
103-
nop;
103+
_5 = move ((_6 as Ok).0: std::ptr::NonNull<[u8]>);
104104
StorageDead(_12);
105105
StorageDead(_6);
106-
StorageLive(_17);
107-
nop;
108-
nop;
109-
StorageDead(_17);
106+
- StorageLive(_17);
107+
+ nop;
108+
_17 = (_5.0: *const [u8]);
109+
- _4 = move _17 as *mut [u8] (PtrToPtr);
110+
- StorageDead(_17);
111+
+ _4 = _17 as *mut [u8] (PtrToPtr);
112+
+ nop;
110113
StorageDead(_5);
111-
nop;
114+
- _3 = move _4 as *mut u8 (PtrToPtr);
115+
+ _3 = _17 as *mut u8 (PtrToPtr);
112116
StorageDead(_4);
113117
StorageDead(_3);
114118
- StorageDead(_1);

‎tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@
4545

4646
bb1: {
4747
StorageDead(_6);
48-
StorageLive(_12);
49-
nop;
50-
nop;
51-
StorageDead(_12);
48+
- StorageLive(_12);
49+
+ nop;
50+
_12 = (_5.0: *const [u8]);
51+
- _4 = move _12 as *mut [u8] (PtrToPtr);
52+
- StorageDead(_12);
53+
+ _4 = _12 as *mut [u8] (PtrToPtr);
54+
+ nop;
5255
StorageDead(_5);
53-
nop;
56+
- _3 = move _4 as *mut u8 (PtrToPtr);
57+
+ _3 = _12 as *mut u8 (PtrToPtr);
5458
StorageDead(_4);
5559
StorageDead(_3);
5660
- StorageDead(_1);

‎tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
}
3232

3333
bb1: {
34-
nop;
34+
- _1 = move (_2.0: i32);
35+
+ _1 = const 4_i32;
3536
StorageLive(_3);
3637
StorageLive(_4);
37-
nop;
38+
_4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32];
3839
StorageLive(_5);
3940
_5 = const 3_usize;
4041
_6 = const 6_usize;
@@ -45,13 +46,15 @@
4546
}
4647

4748
bb2: {
48-
nop;
49+
- _3 = _4[_5];
50+
+ _3 = const 3_i32;
4951
StorageDead(_5);
5052
StorageDead(_4);
5153
StorageLive(_8);
5254
StorageLive(_9);
53-
nop;
54-
nop;
55+
_9 = const 42_u32;
56+
- _8 = _9;
57+
+ _8 = const 42_u32;
5558
StorageDead(_9);
5659
StorageDead(_8);
5760
StorageDead(_3);

‎tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
}
3232

3333
bb1: {
34-
nop;
34+
- _1 = move (_2.0: i32);
35+
+ _1 = const 4_i32;
3536
StorageLive(_3);
3637
StorageLive(_4);
37-
nop;
38+
_4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32];
3839
StorageLive(_5);
3940
_5 = const 3_usize;
4041
_6 = const 6_usize;
@@ -45,13 +46,15 @@
4546
}
4647

4748
bb2: {
48-
nop;
49+
- _3 = _4[_5];
50+
+ _3 = const 3_i32;
4951
StorageDead(_5);
5052
StorageDead(_4);
5153
StorageLive(_8);
5254
StorageLive(_9);
53-
nop;
54-
nop;
55+
_9 = const 42_u32;
56+
- _8 = _9;
57+
+ _8 = const 42_u32;
5558
StorageDead(_9);
5659
StorageDead(_8);
5760
StorageDead(_3);

‎tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
}
3232

3333
bb1: {
34-
nop;
34+
- _1 = move (_2.0: i32);
35+
+ _1 = const 4_i32;
3536
StorageLive(_3);
3637
StorageLive(_4);
37-
nop;
38+
_4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32];
3839
StorageLive(_5);
3940
_5 = const 3_usize;
4041
_6 = const 6_usize;
@@ -45,13 +46,15 @@
4546
}
4647

4748
bb2: {
48-
nop;
49+
- _3 = _4[_5];
50+
+ _3 = const 3_i32;
4951
StorageDead(_5);
5052
StorageDead(_4);
5153
StorageLive(_8);
5254
StorageLive(_9);
53-
nop;
54-
nop;
55+
_9 = const 42_u32;
56+
- _8 = _9;
57+
+ _8 = const 42_u32;
5558
StorageDead(_9);
5659
StorageDead(_8);
5760
StorageDead(_3);

‎tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
}
3232

3333
bb1: {
34-
nop;
34+
- _1 = move (_2.0: i32);
35+
+ _1 = const 4_i32;
3536
StorageLive(_3);
3637
StorageLive(_4);
37-
nop;
38+
_4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32];
3839
StorageLive(_5);
3940
_5 = const 3_usize;
4041
_6 = const 6_usize;
@@ -45,13 +46,15 @@
4546
}
4647

4748
bb2: {
48-
nop;
49+
- _3 = _4[_5];
50+
+ _3 = const 3_i32;
4951
StorageDead(_5);
5052
StorageDead(_4);
5153
StorageLive(_8);
5254
StorageLive(_9);
53-
nop;
54-
nop;
55+
_9 = const 42_u32;
56+
- _8 = _9;
57+
+ _8 = const 42_u32;
5558
StorageDead(_9);
5659
StorageDead(_8);
5760
StorageDead(_3);

‎tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-abort.mir

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,17 @@
22

33
fn main() -> () {
44
let mut _0: ();
5-
let _1: i32;
65
scope 1 {
7-
debug x => _1;
8-
let _2: i32;
6+
debug x => const 4_i32;
97
scope 2 {
10-
debug y => _2;
11-
let _3: u32;
8+
debug y => const 3_i32;
129
scope 3 {
13-
debug z => _3;
10+
debug z => const 42_u32;
1411
}
1512
}
1613
}
1714

1815
bb0: {
19-
StorageLive(_1);
20-
StorageLive(_2);
21-
StorageLive(_3);
22-
StorageDead(_3);
23-
StorageDead(_2);
24-
StorageDead(_1);
2516
return;
2617
}
2718
}

‎tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-unwind.mir

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,17 @@
22

33
fn main() -> () {
44
let mut _0: ();
5-
let _1: i32;
65
scope 1 {
7-
debug x => _1;
8-
let _2: i32;
6+
debug x => const 4_i32;
97
scope 2 {
10-
debug y => _2;
11-
let _3: u32;
8+
debug y => const 3_i32;
129
scope 3 {
13-
debug z => _3;
10+
debug z => const 42_u32;
1411
}
1512
}
1613
}
1714

1815
bb0: {
19-
StorageLive(_1);
20-
StorageLive(_2);
21-
StorageLive(_3);
22-
StorageDead(_3);
23-
StorageDead(_2);
24-
StorageDead(_1);
2516
return;
2617
}
2718
}

‎tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-abort.mir

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,17 @@
22

33
fn main() -> () {
44
let mut _0: ();
5-
let _1: i32;
65
scope 1 {
7-
debug x => _1;
8-
let _2: i32;
6+
debug x => const 4_i32;
97
scope 2 {
10-
debug y => _2;
11-
let _3: u32;
8+
debug y => const 3_i32;
129
scope 3 {
13-
debug z => _3;
10+
debug z => const 42_u32;
1411
}
1512
}
1613
}
1714

1815
bb0: {
19-
StorageLive(_1);
20-
StorageLive(_2);
21-
StorageLive(_3);
22-
StorageDead(_3);
23-
StorageDead(_2);
24-
StorageDead(_1);
2516
return;
2617
}
2718
}

‎tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-unwind.mir

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,17 @@
22

33
fn main() -> () {
44
let mut _0: ();
5-
let _1: i32;
65
scope 1 {
7-
debug x => _1;
8-
let _2: i32;
6+
debug x => const 4_i32;
97
scope 2 {
10-
debug y => _2;
11-
let _3: u32;
8+
debug y => const 3_i32;
129
scope 3 {
13-
debug z => _3;
10+
debug z => const 42_u32;
1411
}
1512
}
1613
}
1714

1815
bb0: {
19-
StorageLive(_1);
20-
StorageLive(_2);
21-
StorageLive(_3);
22-
StorageDead(_3);
23-
StorageDead(_2);
24-
StorageDead(_1);
2516
return;
2617
}
2718
}

‎tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-abort.mir

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,17 @@
22

33
fn main() -> () {
44
let mut _0: ();
5-
let _1: i32;
65
scope 1 {
7-
debug x => _1;
8-
let _2: i32;
6+
debug x => const 4_i32;
97
scope 2 {
10-
debug y => _2;
11-
let _3: u32;
8+
debug y => const 3_i32;
129
scope 3 {
13-
debug z => _3;
10+
debug z => const 42_u32;
1411
}
1512
}
1613
}
1714

1815
bb0: {
19-
StorageLive(_1);
20-
StorageLive(_2);
21-
StorageLive(_3);
22-
StorageDead(_3);
23-
StorageDead(_2);
24-
StorageDead(_1);
2516
return;
2617
}
2718
}

‎tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-unwind.mir

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,17 @@
22

33
fn main() -> () {
44
let mut _0: ();
5-
let _1: i32;
65
scope 1 {
7-
debug x => _1;
8-
let _2: i32;
6+
debug x => const 4_i32;
97
scope 2 {
10-
debug y => _2;
11-
let _3: u32;
8+
debug y => const 3_i32;
129
scope 3 {
13-
debug z => _3;
10+
debug z => const 42_u32;
1411
}
1512
}
1613
}
1714

1815
bb0: {
19-
StorageLive(_1);
20-
StorageLive(_2);
21-
StorageLive(_3);
22-
StorageDead(_3);
23-
StorageDead(_2);
24-
StorageDead(_1);
2516
return;
2617
}
2718
}

‎tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-abort.mir

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,17 @@
22

33
fn main() -> () {
44
let mut _0: ();
5-
let _1: i32;
65
scope 1 {
7-
debug x => _1;
8-
let _2: i32;
6+
debug x => const 4_i32;
97
scope 2 {
10-
debug y => _2;
11-
let _3: u32;
8+
debug y => const 3_i32;
129
scope 3 {
13-
debug z => _3;
10+
debug z => const 42_u32;
1411
}
1512
}
1613
}
1714

1815
bb0: {
19-
StorageLive(_1);
20-
StorageLive(_2);
21-
StorageLive(_3);
22-
StorageDead(_3);
23-
StorageDead(_2);
24-
StorageDead(_1);
2516
return;
2617
}
2718
}

‎tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-unwind.mir

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,17 @@
22

33
fn main() -> () {
44
let mut _0: ();
5-
let _1: i32;
65
scope 1 {
7-
debug x => _1;
8-
let _2: i32;
6+
debug x => const 4_i32;
97
scope 2 {
10-
debug y => _2;
11-
let _3: u32;
8+
debug y => const 3_i32;
129
scope 3 {
13-
debug z => _3;
10+
debug z => const 42_u32;
1411
}
1512
}
1613
}
1714

1815
bb0: {
19-
StorageLive(_1);
20-
StorageLive(_2);
21-
StorageLive(_3);
22-
StorageDead(_3);
23-
StorageDead(_2);
24-
StorageDead(_1);
2516
return;
2617
}
2718
}

‎tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
1010
let mut _11: &impl Fn(u32);
1111
let mut _12: (u32,);
1212
let _13: ();
13+
let mut _14: u32;
1314
scope 1 {
1415
debug ((iter: std::ops::Range<u32>).0: u32) => _4;
15-
debug ((iter: std::ops::Range<u32>).1: u32) => _2;
16+
debug ((iter: std::ops::Range<u32>).1: u32) => _14;
1617
let _10: u32;
1718
scope 2 {
1819
debug x => _10;
@@ -35,6 +36,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
3536

3637
bb0: {
3738
StorageLive(_4);
39+
StorageLive(_14);
3840
_4 = _1;
3941
goto -> bb1;
4042
}
@@ -55,6 +57,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
5557
StorageDead(_7);
5658
StorageDead(_9);
5759
StorageDead(_4);
60+
StorageDead(_14);
5861
drop(_3) -> [return: bb3, unwind unreachable];
5962
}
6063

‎tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
1010
let mut _11: &impl Fn(u32);
1111
let mut _12: (u32,);
1212
let _13: ();
13+
let mut _14: u32;
1314
scope 1 {
1415
debug ((iter: std::ops::Range<u32>).0: u32) => _4;
15-
debug ((iter: std::ops::Range<u32>).1: u32) => _2;
16+
debug ((iter: std::ops::Range<u32>).1: u32) => _14;
1617
let _10: u32;
1718
scope 2 {
1819
debug x => _10;
@@ -35,6 +36,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
3536

3637
bb0: {
3738
StorageLive(_4);
39+
StorageLive(_14);
3840
_4 = _1;
3941
goto -> bb1;
4042
}
@@ -55,6 +57,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
5557
StorageDead(_7);
5658
StorageDead(_9);
5759
StorageDead(_4);
60+
StorageDead(_14);
5861
drop(_3) -> [return: bb3, unwind continue];
5962
}
6063

‎tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
1212
let mut _14: &impl Fn(usize, &T);
1313
let mut _15: (usize, &T);
1414
let _16: ();
15+
let mut _17: usize;
1516
scope 1 {
1617
debug ((iter: std::ops::Range<usize>).0: usize) => _4;
17-
debug ((iter: std::ops::Range<usize>).1: usize) => _3;
18+
debug ((iter: std::ops::Range<usize>).1: usize) => _17;
1819
let _10: usize;
1920
scope 2 {
2021
debug i => _10;
@@ -42,6 +43,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
4243
bb0: {
4344
_3 = PtrMetadata(_1);
4445
StorageLive(_4);
46+
StorageLive(_17);
4547
_4 = const 0_usize;
4648
goto -> bb1;
4749
}
@@ -62,6 +64,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
6264
StorageDead(_7);
6365
StorageDead(_9);
6466
StorageDead(_4);
67+
StorageDead(_17);
6568
drop(_2) -> [return: bb3, unwind unreachable];
6669
}
6770

‎tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
1212
let mut _14: &impl Fn(usize, &T);
1313
let mut _15: (usize, &T);
1414
let _16: ();
15+
let mut _17: usize;
1516
scope 1 {
1617
debug ((iter: std::ops::Range<usize>).0: usize) => _4;
17-
debug ((iter: std::ops::Range<usize>).1: usize) => _3;
18+
debug ((iter: std::ops::Range<usize>).1: usize) => _17;
1819
let _10: usize;
1920
scope 2 {
2021
debug i => _10;
@@ -42,6 +43,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
4243
bb0: {
4344
_3 = PtrMetadata(_1);
4445
StorageLive(_4);
46+
StorageLive(_17);
4547
_4 = const 0_usize;
4648
goto -> bb1;
4749
}
@@ -62,6 +64,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
6264
StorageDead(_7);
6365
StorageDead(_9);
6466
StorageDead(_4);
67+
StorageDead(_17);
6568
drop(_2) -> [return: bb3, unwind continue];
6669
}
6770

‎tests/mir-opt/separate_const_switch.too_complex.JumpThreading.diff

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555

5656
bb5: {
5757
StorageLive(_8);
58+
nop;
5859
_0 = const Option::<i32>::None;
5960
StorageDead(_8);
6061
goto -> bb7;

‎tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ LL | const C: () = panic!();
77
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
88

99
note: erroneous constant encountered
10-
--> $DIR/collect-in-promoted-const.rs:17:21
10+
--> $DIR/collect-in-promoted-const.rs:20:21
1111
|
1212
LL | let _val = &Fail::<T>::C;
1313
| ^^^^^^^^^^^^
1414

1515
note: the above error was encountered while instantiating `fn f::<i32>`
16-
--> $DIR/collect-in-promoted-const.rs:22:5
16+
--> $DIR/collect-in-promoted-const.rs:25:5
1717
|
1818
LL | f::<i32>();
1919
| ^^^^^^^^^^
Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
error[E0080]: evaluation of `Fail::<T>::C` failed
2+
--> $DIR/collect-in-promoted-const.rs:9:19
3+
|
4+
LL | const C: () = panic!();
5+
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-promoted-const.rs:9:19
6+
|
7+
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
8+
9+
note: erroneous constant encountered
10+
--> $DIR/collect-in-promoted-const.rs:20:21
11+
|
12+
LL | let _val = &Fail::<T>::C;
13+
| ^^^^^^^^^^^^
14+
115
error[E0080]: evaluation of `Fail::<i32>::C` failed
216
--> $DIR/collect-in-promoted-const.rs:9:19
317
|
@@ -7,17 +21,19 @@ LL | const C: () = panic!();
721
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
822

923
note: erroneous constant encountered
10-
--> $DIR/collect-in-promoted-const.rs:17:21
24+
--> $DIR/collect-in-promoted-const.rs:20:21
1125
|
1226
LL | let _val = &Fail::<T>::C;
1327
| ^^^^^^^^^^^^
28+
|
29+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1430

1531
note: the above error was encountered while instantiating `fn f::<i32>`
16-
--> $DIR/collect-in-promoted-const.rs:22:5
32+
--> $DIR/collect-in-promoted-const.rs:25:5
1733
|
1834
LL | f::<i32>();
1935
| ^^^^^^^^^^
2036

21-
error: aborting due to 1 previous error
37+
error: aborting due to 2 previous errors
2238

2339
For more information about this error, try `rustc --explain E0080`.

‎tests/ui/consts/required-consts/collect-in-promoted-const.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
struct Fail<T>(T);
88
impl<T> Fail<T> {
99
const C: () = panic!(); //~ERROR evaluation of `Fail::<i32>::C` failed
10+
//[opt]~^ ERROR evaluation of `Fail::<T>::C` failed
11+
// (Not sure why optimizations lead to this being emitted twice, but as long as compilation
12+
// fails either way it's fine.)
1013
}
1114

1215
#[inline(never)]

0 commit comments

Comments
 (0)
Please sign in to comment.