Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cbe7c5c

Browse files
committedAug 11, 2020
Auto merge of rust-lang#73656 - oli-obk:deaggregate-is-cleanup, r=wesleywiser
move Deaggregate pass to post_borrowck_cleanup Reopen of rust-lang#71946 Only the second commit is from this PR, the other commit is a bugfix that's in the process of getting merged. I'll rebase once that's done In rust-lang#70073 MIR pass handling got reorganized, but with the goal of not changing behavior (except for disabling some optimizations on opt-level = 0). But there we realized that the Deaggregator pass, while conceptually more of a "cleanup" pass (and one that should be run before optimizations), was run in the middle of the optimization chain. Likely this is an accident of history, so I suggest we try and clean that up by making it a proper cleanup pass. This does change mir-opt output, because deaggregation now runs before const-prop instead of after. r? @wesleywiser @rust-lang/wg-mir-opt cc @RalfJung
2 parents 4b9ac51 + 307d0d8 commit cbe7c5c

File tree

40 files changed

+793
-357
lines changed

40 files changed

+793
-357
lines changed
 

‎src/librustc_mir/interpret/step.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
7474
Ok(true)
7575
}
7676

77-
fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> {
77+
/// Runs the interpretation logic for the given `mir::Statement` at the current frame and
78+
/// statement counter. This also moves the statement counter forward.
79+
crate fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> {
7880
info!("{:?}", stmt);
7981

8082
use rustc_middle::mir::StatementKind::*;

‎src/librustc_mir/transform/const_prop.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
252252
throw_machine_stop_str!("tried to write to a local that is marked as not propagatable")
253253
}
254254
if frame == 0 && ecx.machine.only_propagate_inside_block_locals.contains(local) {
255+
trace!(
256+
"mutating local {:?} which is restricted to its block. \
257+
Will remove it from const-prop after block is finished.",
258+
local
259+
);
255260
ecx.machine.written_only_inside_own_block_locals.insert(local);
256261
}
257262
ecx.machine.stack[frame].locals[local].access_mut()
@@ -427,6 +432,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
427432
match f(self) {
428433
Ok(val) => Some(val),
429434
Err(error) => {
435+
trace!("InterpCx operation failed: {:?}", error);
430436
// Some errors shouldn't come up because creating them causes
431437
// an allocation, which we should avoid. When that happens,
432438
// dedicated error variants should be introduced instead.
@@ -969,10 +975,10 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
969975
ConstPropMode::OnlyPropagateInto => {}
970976
other @ ConstPropMode::FullConstProp => {
971977
trace!(
972-
"local {:?} can't be propagated because of multiple assignments",
973-
local,
978+
"local {:?} can't be propagated because of multiple assignments. Previous state: {:?}",
979+
local, other,
974980
);
975-
*other = ConstPropMode::OnlyPropagateInto;
981+
*other = ConstPropMode::OnlyInsideOwnBlock;
976982
}
977983
}
978984
}
@@ -1089,6 +1095,20 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
10891095
}
10901096
} else {
10911097
match statement.kind {
1098+
StatementKind::SetDiscriminant { ref place, .. } => {
1099+
match self.ecx.machine.can_const_prop[place.local] {
1100+
ConstPropMode::FullConstProp | ConstPropMode::OnlyInsideOwnBlock => {
1101+
if self.use_ecx(|this| this.ecx.statement(statement)).is_some() {
1102+
trace!("propped discriminant into {:?}", place);
1103+
} else {
1104+
Self::remove_const(&mut self.ecx, place.local);
1105+
}
1106+
}
1107+
ConstPropMode::OnlyPropagateInto | ConstPropMode::NoPropagation => {
1108+
Self::remove_const(&mut self.ecx, place.local);
1109+
}
1110+
}
1111+
}
10921112
StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => {
10931113
let frame = self.ecx.frame_mut();
10941114
frame.locals[local].value =

‎src/librustc_mir/transform/mod.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,9 @@ fn run_post_borrowck_cleanup_passes<'tcx>(
408408
// but before optimizations begin.
409409
&add_retag::AddRetag,
410410
&simplify::SimplifyCfg::new("elaborate-drops"),
411+
// `Deaggregator` is conceptually part of MIR building, some backends rely on it happening
412+
// and it can help optimizations.
413+
&deaggregator::Deaggregator,
411414
];
412415

413416
run_passes(
@@ -439,11 +442,6 @@ fn run_optimization_passes<'tcx>(
439442
&instcombine::InstCombine,
440443
&const_prop::ConstProp,
441444
&simplify_branches::SimplifyBranches::new("after-const-prop"),
442-
// Run deaggregation here because:
443-
// 1. Some codegen backends require it
444-
// 2. It creates additional possibilities for some MIR optimizations to trigger
445-
// FIXME(#70073): Why is this done here and not in `post_borrowck_cleanup`?
446-
&deaggregator::Deaggregator,
447445
&simplify_try::SimplifyArmIdentity,
448446
&simplify_try::SimplifyBranchSame,
449447
&copy_prop::CopyPropagation,
@@ -460,9 +458,6 @@ fn run_optimization_passes<'tcx>(
460458
&generator::StateTransform,
461459
// FIXME(#70073): This pass is responsible for both optimization as well as some lints.
462460
&const_prop::ConstProp,
463-
// Even if we don't do optimizations, still run deaggregation because some backends assume
464-
// that deaggregation always occurs.
465-
&deaggregator::Deaggregator,
466461
];
467462

468463
let pre_codegen_cleanup: &[&dyn MirPass<'tcx>] = &[

‎src/test/codegen/consts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
// CHECK: @STATIC = {{.*}}, align 4
1111

1212
// This checks the constants from inline_enum_const
13-
// CHECK: @alloc7 = {{.*}}, align 2
13+
// CHECK: @alloc8 = {{.*}}, align 2
1414

1515
// This checks the constants from {low,high}_align_const, they share the same
1616
// constant, but the alignment differs, so the higher one should be used
17-
// CHECK: [[LOW_HIGH:@[0-9]+]] = {{.*}} getelementptr inbounds (<{ [8 x i8] }>, <{ [8 x i8] }>* @alloc19, i32 0, i32 0, i32 0), {{.*}}
17+
// CHECK: [[LOW_HIGH:@[0-9]+]] = {{.*}} getelementptr inbounds (<{ [8 x i8] }>, <{ [8 x i8] }>* @alloc20, i32 0, i32 0, i32 0), {{.*}}
1818

1919
#[derive(Copy, Clone)]
2020
// repr(i16) is required for the {low,high}_align_const test

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@
1414
StorageLive(_1); // scope 0 at $DIR/aggregate.rs:5:9: 5:10
1515
StorageLive(_2); // scope 0 at $DIR/aggregate.rs:5:13: 5:24
1616
StorageLive(_3); // scope 0 at $DIR/aggregate.rs:5:13: 5:22
17-
_3 = (const 0_i32, const 1_i32, const 2_i32); // scope 0 at $DIR/aggregate.rs:5:13: 5:22
17+
(_3.0: i32) = const 0_i32; // scope 0 at $DIR/aggregate.rs:5:13: 5:22
1818
// ty::Const
1919
// + ty: i32
2020
// + val: Value(Scalar(0x00000000))
2121
// mir::Constant
2222
// + span: $DIR/aggregate.rs:5:14: 5:15
2323
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
24+
(_3.1: i32) = const 1_i32; // scope 0 at $DIR/aggregate.rs:5:13: 5:22
2425
// ty::Const
2526
// + ty: i32
2627
// + val: Value(Scalar(0x00000001))
2728
// mir::Constant
2829
// + span: $DIR/aggregate.rs:5:17: 5:18
2930
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
31+
(_3.2: i32) = const 2_i32; // scope 0 at $DIR/aggregate.rs:5:13: 5:22
3032
// ty::Const
3133
// + ty: i32
3234
// + val: Value(Scalar(0x00000002))

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

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,16 @@
1515
StorageLive(_1); // scope 0 at $DIR/discriminant.rs:11:9: 11:10
1616
StorageLive(_2); // scope 0 at $DIR/discriminant.rs:11:13: 11:64
1717
StorageLive(_3); // scope 0 at $DIR/discriminant.rs:11:34: 11:44
18-
- _3 = std::option::Option::<bool>::Some(const true); // scope 0 at $DIR/discriminant.rs:11:34: 11:44
19-
+ _3 = const std::option::Option::<bool>::Some(true); // scope 0 at $DIR/discriminant.rs:11:34: 11:44
18+
((_3 as Some).0: bool) = const true; // scope 0 at $DIR/discriminant.rs:11:34: 11:44
2019
// ty::Const
21-
- // + ty: bool
22-
+ // + ty: std::option::Option<bool>
20+
// + ty: bool
2321
// + val: Value(Scalar(0x01))
2422
// mir::Constant
25-
- // + span: $DIR/discriminant.rs:11:39: 11:43
26-
- // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
23+
// + span: $DIR/discriminant.rs:11:39: 11:43
24+
// + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
25+
discriminant(_3) = 1; // scope 0 at $DIR/discriminant.rs:11:34: 11:44
2726
- _4 = discriminant(_3); // scope 0 at $DIR/discriminant.rs:11:21: 11:31
2827
- switchInt(move _4) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/discriminant.rs:11:21: 11:31
29-
+ // + span: $DIR/discriminant.rs:11:34: 11:44
30-
+ // + literal: Const { ty: std::option::Option<bool>, val: Value(Scalar(0x01)) }
3128
+ _4 = const 1_isize; // scope 0 at $DIR/discriminant.rs:11:21: 11:31
3229
+ // ty::Const
3330
+ // + ty: isize
@@ -56,14 +53,7 @@
5653
}
5754

5855
bb2: {
59-
- switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:11:26: 11:30
60-
+ switchInt(const true) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:11:26: 11:30
61-
+ // ty::Const
62-
+ // + ty: bool
63-
+ // + val: Value(Scalar(0x01))
64-
+ // mir::Constant
65-
+ // + span: $DIR/discriminant.rs:11:26: 11:30
66-
+ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
56+
switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:11:26: 11:30
6757
}
6858

6959
bb3: {

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

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,16 @@
1515
StorageLive(_1); // scope 0 at $DIR/discriminant.rs:11:9: 11:10
1616
StorageLive(_2); // scope 0 at $DIR/discriminant.rs:11:13: 11:64
1717
StorageLive(_3); // scope 0 at $DIR/discriminant.rs:11:34: 11:44
18-
- _3 = std::option::Option::<bool>::Some(const true); // scope 0 at $DIR/discriminant.rs:11:34: 11:44
19-
+ _3 = const std::option::Option::<bool>::Some(true); // scope 0 at $DIR/discriminant.rs:11:34: 11:44
18+
((_3 as Some).0: bool) = const true; // scope 0 at $DIR/discriminant.rs:11:34: 11:44
2019
// ty::Const
21-
- // + ty: bool
22-
+ // + ty: std::option::Option<bool>
20+
// + ty: bool
2321
// + val: Value(Scalar(0x01))
2422
// mir::Constant
25-
- // + span: $DIR/discriminant.rs:11:39: 11:43
26-
- // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
23+
// + span: $DIR/discriminant.rs:11:39: 11:43
24+
// + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
25+
discriminant(_3) = 1; // scope 0 at $DIR/discriminant.rs:11:34: 11:44
2726
- _4 = discriminant(_3); // scope 0 at $DIR/discriminant.rs:11:21: 11:31
2827
- switchInt(move _4) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/discriminant.rs:11:21: 11:31
29-
+ // + span: $DIR/discriminant.rs:11:34: 11:44
30-
+ // + literal: Const { ty: std::option::Option<bool>, val: Value(Scalar(0x01)) }
3128
+ _4 = const 1_isize; // scope 0 at $DIR/discriminant.rs:11:21: 11:31
3229
+ // ty::Const
3330
+ // + ty: isize
@@ -56,14 +53,7 @@
5653
}
5754

5855
bb2: {
59-
- switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:11:26: 11:30
60-
+ switchInt(const true) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:11:26: 11:30
61-
+ // ty::Const
62-
+ // + ty: bool
63-
+ // + val: Value(Scalar(0x01))
64-
+ // mir::Constant
65-
+ // + span: $DIR/discriminant.rs:11:26: 11:30
66-
+ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
56+
switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // scope 0 at $DIR/discriminant.rs:11:26: 11:30
6757
}
6858

6959
bb3: {

‎src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,22 @@
1111
StorageLive(_1); // scope 0 at $DIR/issue-66971.rs:16:5: 16:23
1212
StorageLive(_2); // scope 0 at $DIR/issue-66971.rs:16:12: 16:22
1313
StorageLive(_3); // scope 0 at $DIR/issue-66971.rs:16:13: 16:15
14-
- _3 = (); // scope 0 at $DIR/issue-66971.rs:16:13: 16:15
15-
+ _3 = const (); // scope 0 at $DIR/issue-66971.rs:16:13: 16:15
14+
- (_2.0: ()) = move _3; // scope 0 at $DIR/issue-66971.rs:16:12: 16:22
15+
+ (_2.0: ()) = const (); // scope 0 at $DIR/issue-66971.rs:16:12: 16:22
1616
+ // ty::Const
1717
+ // + ty: ()
1818
+ // + val: Value(Scalar(<ZST>))
1919
+ // mir::Constant
20-
+ // + span: $DIR/issue-66971.rs:16:13: 16:15
20+
+ // + span: $DIR/issue-66971.rs:16:12: 16:22
2121
+ // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
22-
_2 = (move _3, const 0_u8, const 0_u8); // scope 0 at $DIR/issue-66971.rs:16:12: 16:22
22+
(_2.1: u8) = const 0_u8; // scope 0 at $DIR/issue-66971.rs:16:12: 16:22
2323
// ty::Const
2424
// + ty: u8
2525
// + val: Value(Scalar(0x00))
2626
// mir::Constant
2727
// + span: $DIR/issue-66971.rs:16:17: 16:18
2828
// + literal: Const { ty: u8, val: Value(Scalar(0x00)) }
29+
(_2.2: u8) = const 0_u8; // scope 0 at $DIR/issue-66971.rs:16:12: 16:22
2930
// ty::Const
3031
// + ty: u8
3132
// + val: Value(Scalar(0x00))

‎src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,34 @@
1111
StorageLive(_1); // scope 0 at $DIR/issue-67019.rs:11:5: 11:20
1212
StorageLive(_2); // scope 0 at $DIR/issue-67019.rs:11:10: 11:19
1313
StorageLive(_3); // scope 0 at $DIR/issue-67019.rs:11:11: 11:17
14-
_3 = (const 1_u8, const 2_u8); // scope 0 at $DIR/issue-67019.rs:11:11: 11:17
14+
(_3.0: u8) = const 1_u8; // scope 0 at $DIR/issue-67019.rs:11:11: 11:17
1515
// ty::Const
1616
// + ty: u8
1717
// + val: Value(Scalar(0x01))
1818
// mir::Constant
19-
- // + span: $DIR/issue-67019.rs:11:12: 11:13
20-
+ // + span: $DIR/issue-67019.rs:11:11: 11:17
19+
// + span: $DIR/issue-67019.rs:11:12: 11:13
2120
// + literal: Const { ty: u8, val: Value(Scalar(0x01)) }
21+
(_3.1: u8) = const 2_u8; // scope 0 at $DIR/issue-67019.rs:11:11: 11:17
2222
// ty::Const
2323
// + ty: u8
2424
// + val: Value(Scalar(0x02))
2525
// mir::Constant
26-
- // + span: $DIR/issue-67019.rs:11:15: 11:16
27-
+ // + span: $DIR/issue-67019.rs:11:11: 11:17
26+
// + span: $DIR/issue-67019.rs:11:15: 11:16
2827
// + literal: Const { ty: u8, val: Value(Scalar(0x02)) }
29-
_2 = (move _3,); // scope 0 at $DIR/issue-67019.rs:11:10: 11:19
28+
- (_2.0: (u8, u8)) = move _3; // scope 0 at $DIR/issue-67019.rs:11:10: 11:19
29+
+ (_2.0: (u8, u8)) = (const 1_u8, const 2_u8); // scope 0 at $DIR/issue-67019.rs:11:10: 11:19
30+
+ // ty::Const
31+
+ // + ty: u8
32+
+ // + val: Value(Scalar(0x01))
33+
+ // mir::Constant
34+
+ // + span: $DIR/issue-67019.rs:11:10: 11:19
35+
+ // + literal: Const { ty: u8, val: Value(Scalar(0x01)) }
36+
+ // ty::Const
37+
+ // + ty: u8
38+
+ // + val: Value(Scalar(0x02))
39+
+ // mir::Constant
40+
+ // + span: $DIR/issue-67019.rs:11:10: 11:19
41+
+ // + literal: Const { ty: u8, val: Value(Scalar(0x02)) }
3042
StorageDead(_3); // scope 0 at $DIR/issue-67019.rs:11:18: 11:19
3143
_1 = const test(move _2) -> bb1; // scope 0 at $DIR/issue-67019.rs:11:5: 11:20
3244
// ty::Const

‎src/test/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,19 @@
1414

1515
bb0: {
1616
StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:5:9: 5:14
17-
_1 = (const 42_i32, const 43_i32); // scope 0 at $DIR/mutable_variable_aggregate.rs:5:17: 5:25
17+
(_1.0: i32) = const 42_i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:5:17: 5:25
1818
// ty::Const
1919
// + ty: i32
2020
// + val: Value(Scalar(0x0000002a))
2121
// mir::Constant
22-
- // + span: $DIR/mutable_variable_aggregate.rs:5:18: 5:20
23-
+ // + span: $DIR/mutable_variable_aggregate.rs:5:17: 5:25
22+
// + span: $DIR/mutable_variable_aggregate.rs:5:18: 5:20
2423
// + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) }
24+
(_1.1: i32) = const 43_i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:5:17: 5:25
2525
// ty::Const
2626
// + ty: i32
2727
// + val: Value(Scalar(0x0000002b))
2828
// mir::Constant
29-
- // + span: $DIR/mutable_variable_aggregate.rs:5:22: 5:24
30-
+ // + span: $DIR/mutable_variable_aggregate.rs:5:17: 5:25
29+
// + span: $DIR/mutable_variable_aggregate.rs:5:22: 5:24
3130
// + literal: Const { ty: i32, val: Value(Scalar(0x0000002b)) }
3231
(_1.1: i32) = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:6:5: 6:13
3332
// ty::Const

‎src/test/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818

1919
bb0: {
2020
StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:5:9: 5:14
21-
_1 = (const 42_i32, const 43_i32); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:5:17: 5:25
21+
(_1.0: i32) = const 42_i32; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:5:17: 5:25
2222
// ty::Const
2323
// + ty: i32
2424
// + val: Value(Scalar(0x0000002a))
2525
// mir::Constant
2626
// + span: $DIR/mutable_variable_aggregate_mut_ref.rs:5:18: 5:20
2727
// + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) }
28+
(_1.1: i32) = const 43_i32; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:5:17: 5:25
2829
// ty::Const
2930
// + ty: i32
3031
// + val: Value(Scalar(0x0000002b))

‎src/test/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,19 @@
3434

3535
bb1: {
3636
StorageLive(_2); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:6:9: 6:14
37-
_2 = (const 1_i32, const 2_i32); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:6:29: 6:35
37+
(_2.0: i32) = const 1_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:6:29: 6:35
3838
// ty::Const
3939
// + ty: i32
4040
// + val: Value(Scalar(0x00000001))
4141
// mir::Constant
42-
- // + span: $DIR/mutable_variable_unprop_assign.rs:6:30: 6:31
43-
+ // + span: $DIR/mutable_variable_unprop_assign.rs:6:29: 6:35
42+
// + span: $DIR/mutable_variable_unprop_assign.rs:6:30: 6:31
4443
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
44+
(_2.1: i32) = const 2_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:6:29: 6:35
4545
// ty::Const
4646
// + ty: i32
4747
// + val: Value(Scalar(0x00000002))
4848
// mir::Constant
49-
- // + span: $DIR/mutable_variable_unprop_assign.rs:6:33: 6:34
50-
+ // + span: $DIR/mutable_variable_unprop_assign.rs:6:29: 6:35
49+
// + span: $DIR/mutable_variable_unprop_assign.rs:6:33: 6:34
5150
// + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) }
5251
StorageLive(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:7:11: 7:12
5352
_3 = _1; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:7:11: 7:12

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,14 @@
173173
StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35
174174
StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
175175
StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
176-
_9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
176+
(_9.0: u32) = const 12_u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
177177
// ty::Const
178178
// + ty: u32
179179
// + val: Value(Scalar(0x0000000c))
180180
// mir::Constant
181181
// + span: $DIR/optimizes_into_variable.rs:14:25: 14:27
182182
// + literal: Const { ty: u32, val: Value(Scalar(0x0000000c)) }
183+
(_9.1: u32) = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
183184
// ty::Const
184185
// + ty: u32
185186
// + val: Value(Scalar(0x0000002a))

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,14 @@
173173
StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35
174174
StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10
175175
StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
176-
_9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
176+
(_9.0: u32) = const 12_u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
177177
// ty::Const
178178
// + ty: u32
179179
// + val: Value(Scalar(0x0000000c))
180180
// mir::Constant
181181
// + span: $DIR/optimizes_into_variable.rs:14:25: 14:27
182182
// + literal: Const { ty: u32, val: Value(Scalar(0x0000000c)) }
183+
(_9.1: u32) = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36
183184
// ty::Const
184185
// + ty: u32
185186
// + val: Value(Scalar(0x0000002a))

‎src/test/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,19 @@
1212

1313
bb0: {
1414
StorageLive(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:3:9: 3:10
15-
_1 = (const 1_u32, const 2_u32); // scope 0 at $DIR/tuple_literal_propagation.rs:3:13: 3:19
15+
(_1.0: u32) = const 1_u32; // scope 0 at $DIR/tuple_literal_propagation.rs:3:13: 3:19
1616
// ty::Const
1717
// + ty: u32
1818
// + val: Value(Scalar(0x00000001))
1919
// mir::Constant
20-
- // + span: $DIR/tuple_literal_propagation.rs:3:14: 3:15
21-
+ // + span: $DIR/tuple_literal_propagation.rs:3:13: 3:19
20+
// + span: $DIR/tuple_literal_propagation.rs:3:14: 3:15
2221
// + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
22+
(_1.1: u32) = const 2_u32; // scope 0 at $DIR/tuple_literal_propagation.rs:3:13: 3:19
2323
// ty::Const
2424
// + ty: u32
2525
// + val: Value(Scalar(0x00000002))
2626
// mir::Constant
27-
- // + span: $DIR/tuple_literal_propagation.rs:3:17: 3:18
28-
+ // + span: $DIR/tuple_literal_propagation.rs:3:13: 3:19
27+
// + span: $DIR/tuple_literal_propagation.rs:3:17: 3:18
2928
// + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) }
3029
StorageLive(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:5:5: 5:15
3130
StorageLive(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:5:13: 5:14

‎src/test/mir-opt/const_prop_miscompile.bar.ConstProp.diff

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,13 @@
1919

2020
bb0: {
2121
StorageLive(_1); // scope 0 at $DIR/const_prop_miscompile.rs:12:9: 12:14
22-
- _1 = (const 1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:12:17: 12:21
23-
+ _1 = const (1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:12:17: 12:21
22+
(_1.0: i32) = const 1_i32; // scope 0 at $DIR/const_prop_miscompile.rs:12:17: 12:21
2423
// ty::Const
25-
- // + ty: i32
26-
+ // + ty: (i32,)
24+
// + ty: i32
2725
// + val: Value(Scalar(0x00000001))
2826
// mir::Constant
29-
- // + span: $DIR/const_prop_miscompile.rs:12:18: 12:19
30-
- // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
31-
+ // + span: $DIR/const_prop_miscompile.rs:12:17: 12:21
32-
+ // + literal: Const { ty: (i32,), val: Value(Scalar(0x00000001)) }
27+
// + span: $DIR/const_prop_miscompile.rs:12:18: 12:19
28+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
3329
StorageLive(_2); // scope 1 at $DIR/const_prop_miscompile.rs:13:5: 15:6
3430
StorageLive(_3); // scope 2 at $DIR/const_prop_miscompile.rs:14:10: 14:22
3531
_3 = &raw mut (_1.0: i32); // scope 2 at $DIR/const_prop_miscompile.rs:14:10: 14:22

‎src/test/mir-opt/const_prop_miscompile.foo.ConstProp.diff

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,13 @@
1616

1717
bb0: {
1818
StorageLive(_1); // scope 0 at $DIR/const_prop_miscompile.rs:5:9: 5:14
19-
- _1 = (const 1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:5:17: 5:21
20-
+ _1 = const (1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:5:17: 5:21
19+
(_1.0: i32) = const 1_i32; // scope 0 at $DIR/const_prop_miscompile.rs:5:17: 5:21
2120
// ty::Const
22-
- // + ty: i32
23-
+ // + ty: (i32,)
21+
// + ty: i32
2422
// + val: Value(Scalar(0x00000001))
2523
// mir::Constant
26-
- // + span: $DIR/const_prop_miscompile.rs:5:18: 5:19
27-
- // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
28-
+ // + span: $DIR/const_prop_miscompile.rs:5:17: 5:21
29-
+ // + literal: Const { ty: (i32,), val: Value(Scalar(0x00000001)) }
24+
// + span: $DIR/const_prop_miscompile.rs:5:18: 5:19
25+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
3026
StorageLive(_2); // scope 1 at $DIR/const_prop_miscompile.rs:6:6: 6:14
3127
_2 = &mut (_1.0: i32); // scope 1 at $DIR/const_prop_miscompile.rs:6:6: 6:14
3228
(*_2) = const 5_i32; // scope 1 at $DIR/const_prop_miscompile.rs:6:5: 6:18
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
- // MIR for `float_to_exponential_common` before ConstProp
2+
+ // MIR for `float_to_exponential_common` after ConstProp
3+
4+
fn float_to_exponential_common(_1: &mut std::fmt::Formatter, _2: &T, _3: bool) -> std::result::Result<(), std::fmt::Error> {
5+
debug fmt => _1; // in scope 0 at $DIR/funky_arms.rs:11:35: 11:38
6+
debug num => _2; // in scope 0 at $DIR/funky_arms.rs:11:60: 11:63
7+
debug upper => _3; // in scope 0 at $DIR/funky_arms.rs:11:69: 11:74
8+
let mut _0: std::result::Result<(), std::fmt::Error>; // return place in scope 0 at $DIR/funky_arms.rs:11:85: 11:91
9+
let _4: bool; // in scope 0 at $DIR/funky_arms.rs:15:9: 15:19
10+
let mut _5: &std::fmt::Formatter; // in scope 0 at $DIR/funky_arms.rs:15:22: 15:25
11+
let mut _7: std::option::Option<usize>; // in scope 0 at $DIR/funky_arms.rs:24:30: 24:45
12+
let mut _8: &std::fmt::Formatter; // in scope 0 at $DIR/funky_arms.rs:24:30: 24:33
13+
let mut _9: isize; // in scope 0 at $DIR/funky_arms.rs:24:12: 24:27
14+
let mut _11: &mut std::fmt::Formatter; // in scope 0 at $DIR/funky_arms.rs:26:43: 26:46
15+
let mut _12: &T; // in scope 0 at $DIR/funky_arms.rs:26:48: 26:51
16+
let mut _13: core::num::flt2dec::Sign; // in scope 0 at $DIR/funky_arms.rs:26:53: 26:57
17+
let mut _14: u32; // in scope 0 at $DIR/funky_arms.rs:26:59: 26:79
18+
let mut _15: u32; // in scope 0 at $DIR/funky_arms.rs:26:59: 26:75
19+
let mut _16: usize; // in scope 0 at $DIR/funky_arms.rs:26:59: 26:68
20+
let mut _17: bool; // in scope 0 at $DIR/funky_arms.rs:26:81: 26:86
21+
let mut _18: &mut std::fmt::Formatter; // in scope 0 at $DIR/funky_arms.rs:28:46: 28:49
22+
let mut _19: &T; // in scope 0 at $DIR/funky_arms.rs:28:51: 28:54
23+
let mut _20: core::num::flt2dec::Sign; // in scope 0 at $DIR/funky_arms.rs:28:56: 28:60
24+
let mut _21: bool; // in scope 0 at $DIR/funky_arms.rs:28:62: 28:67
25+
scope 1 {
26+
debug force_sign => _4; // in scope 1 at $DIR/funky_arms.rs:15:9: 15:19
27+
let _6: core::num::flt2dec::Sign; // in scope 1 at $DIR/funky_arms.rs:19:9: 19:13
28+
scope 2 {
29+
debug sign => _6; // in scope 2 at $DIR/funky_arms.rs:19:9: 19:13
30+
let _10: usize; // in scope 2 at $DIR/funky_arms.rs:24:17: 24:26
31+
scope 3 {
32+
debug precision => _10; // in scope 3 at $DIR/funky_arms.rs:24:17: 24:26
33+
}
34+
}
35+
}
36+
37+
bb0: {
38+
StorageLive(_4); // scope 0 at $DIR/funky_arms.rs:15:9: 15:19
39+
StorageLive(_5); // scope 0 at $DIR/funky_arms.rs:15:22: 15:25
40+
_5 = &(*_1); // scope 0 at $DIR/funky_arms.rs:15:22: 15:25
41+
_4 = const std::fmt::Formatter::sign_plus(move _5) -> bb1; // scope 0 at $DIR/funky_arms.rs:15:22: 15:37
42+
// ty::Const
43+
// + ty: for<'r> fn(&'r std::fmt::Formatter) -> bool {std::fmt::Formatter::sign_plus}
44+
// + val: Value(Scalar(<ZST>))
45+
// mir::Constant
46+
// + span: $DIR/funky_arms.rs:15:26: 15:35
47+
// + literal: Const { ty: for<'r> fn(&'r std::fmt::Formatter) -> bool {std::fmt::Formatter::sign_plus}, val: Value(Scalar(<ZST>)) }
48+
}
49+
50+
bb1: {
51+
StorageDead(_5); // scope 0 at $DIR/funky_arms.rs:15:36: 15:37
52+
StorageLive(_6); // scope 1 at $DIR/funky_arms.rs:19:9: 19:13
53+
switchInt(_4) -> [false: bb3, otherwise: bb2]; // scope 1 at $DIR/funky_arms.rs:20:9: 20:14
54+
}
55+
56+
bb2: {
57+
discriminant(_6) = 2; // scope 1 at $DIR/funky_arms.rs:21:17: 21:41
58+
goto -> bb4; // scope 1 at $DIR/funky_arms.rs:19:16: 22:6
59+
}
60+
61+
bb3: {
62+
discriminant(_6) = 0; // scope 1 at $DIR/funky_arms.rs:20:18: 20:38
63+
goto -> bb4; // scope 1 at $DIR/funky_arms.rs:19:16: 22:6
64+
}
65+
66+
bb4: {
67+
StorageLive(_7); // scope 2 at $DIR/funky_arms.rs:24:30: 24:45
68+
StorageLive(_8); // scope 2 at $DIR/funky_arms.rs:24:30: 24:33
69+
_8 = &(*_1); // scope 2 at $DIR/funky_arms.rs:24:30: 24:33
70+
_7 = const std::fmt::Formatter::precision(move _8) -> bb5; // scope 2 at $DIR/funky_arms.rs:24:30: 24:45
71+
// ty::Const
72+
// + ty: for<'r> fn(&'r std::fmt::Formatter) -> std::option::Option<usize> {std::fmt::Formatter::precision}
73+
// + val: Value(Scalar(<ZST>))
74+
// mir::Constant
75+
// + span: $DIR/funky_arms.rs:24:34: 24:43
76+
// + literal: Const { ty: for<'r> fn(&'r std::fmt::Formatter) -> std::option::Option<usize> {std::fmt::Formatter::precision}, val: Value(Scalar(<ZST>)) }
77+
}
78+
79+
bb5: {
80+
StorageDead(_8); // scope 2 at $DIR/funky_arms.rs:24:44: 24:45
81+
_9 = discriminant(_7); // scope 2 at $DIR/funky_arms.rs:24:12: 24:27
82+
switchInt(move _9) -> [1_isize: bb7, otherwise: bb6]; // scope 2 at $DIR/funky_arms.rs:24:12: 24:27
83+
}
84+
85+
bb6: {
86+
StorageLive(_18); // scope 2 at $DIR/funky_arms.rs:28:46: 28:49
87+
_18 = &mut (*_1); // scope 2 at $DIR/funky_arms.rs:28:46: 28:49
88+
StorageLive(_19); // scope 2 at $DIR/funky_arms.rs:28:51: 28:54
89+
_19 = _2; // scope 2 at $DIR/funky_arms.rs:28:51: 28:54
90+
StorageLive(_20); // scope 2 at $DIR/funky_arms.rs:28:56: 28:60
91+
_20 = _6; // scope 2 at $DIR/funky_arms.rs:28:56: 28:60
92+
StorageLive(_21); // scope 2 at $DIR/funky_arms.rs:28:62: 28:67
93+
_21 = _3; // scope 2 at $DIR/funky_arms.rs:28:62: 28:67
94+
_0 = const float_to_exponential_common_shortest::<T>(move _18, move _19, move _20, move _21) -> bb9; // scope 2 at $DIR/funky_arms.rs:28:9: 28:68
95+
// ty::Const
96+
// + ty: for<'r, 's, 't0> fn(&'r mut std::fmt::Formatter<'s>, &'t0 T, core::num::flt2dec::Sign, bool) -> std::result::Result<(), std::fmt::Error> {float_to_exponential_common_shortest::<T>}
97+
// + val: Value(Scalar(<ZST>))
98+
// mir::Constant
99+
// + span: $DIR/funky_arms.rs:28:9: 28:45
100+
// + literal: Const { ty: for<'r, 's, 't0> fn(&'r mut std::fmt::Formatter<'s>, &'t0 T, core::num::flt2dec::Sign, bool) -> std::result::Result<(), std::fmt::Error> {float_to_exponential_common_shortest::<T>}, val: Value(Scalar(<ZST>)) }
101+
}
102+
103+
bb7: {
104+
StorageLive(_10); // scope 2 at $DIR/funky_arms.rs:24:17: 24:26
105+
_10 = ((_7 as Some).0: usize); // scope 2 at $DIR/funky_arms.rs:24:17: 24:26
106+
StorageLive(_11); // scope 3 at $DIR/funky_arms.rs:26:43: 26:46
107+
_11 = &mut (*_1); // scope 3 at $DIR/funky_arms.rs:26:43: 26:46
108+
StorageLive(_12); // scope 3 at $DIR/funky_arms.rs:26:48: 26:51
109+
_12 = _2; // scope 3 at $DIR/funky_arms.rs:26:48: 26:51
110+
StorageLive(_13); // scope 3 at $DIR/funky_arms.rs:26:53: 26:57
111+
_13 = _6; // scope 3 at $DIR/funky_arms.rs:26:53: 26:57
112+
StorageLive(_14); // scope 3 at $DIR/funky_arms.rs:26:59: 26:79
113+
StorageLive(_15); // scope 3 at $DIR/funky_arms.rs:26:59: 26:75
114+
StorageLive(_16); // scope 3 at $DIR/funky_arms.rs:26:59: 26:68
115+
_16 = _10; // scope 3 at $DIR/funky_arms.rs:26:59: 26:68
116+
_15 = move _16 as u32 (Misc); // scope 3 at $DIR/funky_arms.rs:26:59: 26:75
117+
StorageDead(_16); // scope 3 at $DIR/funky_arms.rs:26:74: 26:75
118+
_14 = Add(move _15, const 1_u32); // scope 3 at $DIR/funky_arms.rs:26:59: 26:79
119+
// ty::Const
120+
// + ty: u32
121+
// + val: Value(Scalar(0x00000001))
122+
// mir::Constant
123+
// + span: $DIR/funky_arms.rs:26:78: 26:79
124+
// + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) }
125+
StorageDead(_15); // scope 3 at $DIR/funky_arms.rs:26:78: 26:79
126+
StorageLive(_17); // scope 3 at $DIR/funky_arms.rs:26:81: 26:86
127+
_17 = _3; // scope 3 at $DIR/funky_arms.rs:26:81: 26:86
128+
_0 = const float_to_exponential_common_exact::<T>(move _11, move _12, move _13, move _14, move _17) -> bb8; // scope 3 at $DIR/funky_arms.rs:26:9: 26:87
129+
// ty::Const
130+
// + ty: for<'r, 's, 't0> fn(&'r mut std::fmt::Formatter<'s>, &'t0 T, core::num::flt2dec::Sign, u32, bool) -> std::result::Result<(), std::fmt::Error> {float_to_exponential_common_exact::<T>}
131+
// + val: Value(Scalar(<ZST>))
132+
// mir::Constant
133+
// + span: $DIR/funky_arms.rs:26:9: 26:42
134+
// + literal: Const { ty: for<'r, 's, 't0> fn(&'r mut std::fmt::Formatter<'s>, &'t0 T, core::num::flt2dec::Sign, u32, bool) -> std::result::Result<(), std::fmt::Error> {float_to_exponential_common_exact::<T>}, val: Value(Scalar(<ZST>)) }
135+
}
136+
137+
bb8: {
138+
StorageDead(_17); // scope 3 at $DIR/funky_arms.rs:26:86: 26:87
139+
StorageDead(_14); // scope 3 at $DIR/funky_arms.rs:26:86: 26:87
140+
StorageDead(_13); // scope 3 at $DIR/funky_arms.rs:26:86: 26:87
141+
StorageDead(_12); // scope 3 at $DIR/funky_arms.rs:26:86: 26:87
142+
StorageDead(_11); // scope 3 at $DIR/funky_arms.rs:26:86: 26:87
143+
StorageDead(_10); // scope 2 at $DIR/funky_arms.rs:27:5: 27:6
144+
goto -> bb10; // scope 2 at $DIR/funky_arms.rs:24:5: 29:6
145+
}
146+
147+
bb9: {
148+
StorageDead(_21); // scope 2 at $DIR/funky_arms.rs:28:67: 28:68
149+
StorageDead(_20); // scope 2 at $DIR/funky_arms.rs:28:67: 28:68
150+
StorageDead(_19); // scope 2 at $DIR/funky_arms.rs:28:67: 28:68
151+
StorageDead(_18); // scope 2 at $DIR/funky_arms.rs:28:67: 28:68
152+
goto -> bb10; // scope 2 at $DIR/funky_arms.rs:24:5: 29:6
153+
}
154+
155+
bb10: {
156+
StorageDead(_6); // scope 1 at $DIR/funky_arms.rs:30:1: 30:2
157+
StorageDead(_4); // scope 0 at $DIR/funky_arms.rs:30:1: 30:2
158+
StorageDead(_7); // scope 0 at $DIR/funky_arms.rs:30:1: 30:2
159+
return; // scope 0 at $DIR/funky_arms.rs:30:2: 30:2
160+
}
161+
}
162+

‎src/test/mir-opt/funky_arms.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// compile-flags: --crate-type lib -Cdebug-assertions=no
2+
3+
#![feature(flt2dec)]
4+
5+
extern crate core;
6+
7+
use core::num::flt2dec;
8+
use std::fmt::{Formatter, Result};
9+
10+
// EMIT_MIR funky_arms.float_to_exponential_common.ConstProp.diff
11+
fn float_to_exponential_common<T>(fmt: &mut Formatter<'_>, num: &T, upper: bool) -> Result
12+
where
13+
T: flt2dec::DecodableFloat,
14+
{
15+
let force_sign = fmt.sign_plus();
16+
// A bug in const propagation (never reached master, but during dev of a PR) caused the
17+
// `sign = Minus` assignment to get propagated into all future reads of `sign`. This is
18+
// wrong because `sign` could also have `MinusPlus` value.
19+
let sign = match force_sign {
20+
false => flt2dec::Sign::Minus,
21+
true => flt2dec::Sign::MinusPlus,
22+
};
23+
24+
if let Some(precision) = fmt.precision() {
25+
// 1 integral digit + `precision` fractional digits = `precision + 1` total digits
26+
float_to_exponential_common_exact(fmt, num, sign, precision as u32 + 1, upper)
27+
} else {
28+
float_to_exponential_common_shortest(fmt, num, sign, upper)
29+
}
30+
}
31+
#[inline(never)]
32+
fn float_to_exponential_common_exact<T>(
33+
fmt: &mut Formatter<'_>,
34+
num: &T,
35+
sign: flt2dec::Sign,
36+
precision: u32,
37+
upper: bool,
38+
) -> Result
39+
where
40+
T: flt2dec::DecodableFloat,
41+
{
42+
unimplemented!()
43+
}
44+
45+
#[inline(never)]
46+
fn float_to_exponential_common_shortest<T>(
47+
fmt: &mut Formatter<'_>,
48+
num: &T,
49+
sign: flt2dec::Sign,
50+
upper: bool,
51+
) -> Result
52+
where
53+
T: flt2dec::DecodableFloat,
54+
{
55+
unimplemented!()
56+
}

‎src/test/mir-opt/generator_storage_dead_unwind.main-{{closure}}.StateTransform.before.mir

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ yields ()
2121

2222
bb0: {
2323
StorageLive(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:23:13: 23:14
24-
_3 = Foo(const 5_i32); // scope 0 at $DIR/generator-storage-dead-unwind.rs:23:17: 23:23
24+
(_3.0: i32) = const 5_i32; // scope 0 at $DIR/generator-storage-dead-unwind.rs:23:17: 23:23
2525
// ty::Const
2626
// + ty: i32
2727
// + val: Value(Scalar(0x00000005))
2828
// mir::Constant
2929
// + span: $DIR/generator-storage-dead-unwind.rs:23:21: 23:22
3030
// + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) }
3131
StorageLive(_4); // scope 1 at $DIR/generator-storage-dead-unwind.rs:24:13: 24:14
32-
_4 = Bar(const 6_i32); // scope 1 at $DIR/generator-storage-dead-unwind.rs:24:17: 24:23
32+
(_4.0: i32) = const 6_i32; // scope 1 at $DIR/generator-storage-dead-unwind.rs:24:17: 24:23
3333
// ty::Const
3434
// + ty: i32
3535
// + val: Value(Scalar(0x00000006))
@@ -38,7 +38,6 @@ yields ()
3838
// + literal: Const { ty: i32, val: Value(Scalar(0x00000006)) }
3939
StorageLive(_5); // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14
4040
StorageLive(_6); // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14
41-
_6 = (); // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14
4241
_5 = yield(move _6) -> [resume: bb2, drop: bb4]; // scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14
4342
}
4443

‎src/test/mir-opt/generator_tiny.main-{{closure}}.generator_resume.0.mir

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
// MIR for `main::{{closure}}#0` 0 generator_resume
22
/* generator_layout = GeneratorLayout {
3-
field_tys: {
4-
_0: HasDrop,
5-
},
3+
field_tys: {},
64
variant_fields: {
75
Unresumed(0): [],
86
Returned (1): [],
97
Panicked (2): [],
10-
Suspend0 (3): [_0],
11-
},
12-
storage_conflicts: BitMatrix(1x1) {
13-
(_0, _0),
8+
Suspend0 (3): [],
149
},
10+
storage_conflicts: BitMatrix(0x0) {},
1511
} */
1612

1713
fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs:19:16: 25:6 {u8, HasDrop, ()}]>, _2: u8) -> std::ops::GeneratorState<(), ()> {
@@ -27,7 +23,7 @@ fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs:
2723
let _10: u8; // in scope 0 at $DIR/generator-tiny.rs:19:17: 19:19
2824
let mut _11: u32; // in scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
2925
scope 1 {
30-
debug _d => (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6 {u8, HasDrop, ()}])) as variant#3).0: HasDrop); // in scope 1 at $DIR/generator-tiny.rs:20:13: 20:15
26+
debug _d => _3; // in scope 1 at $DIR/generator-tiny.rs:20:13: 20:15
3127
}
3228

3329
bb0: {
@@ -37,16 +33,14 @@ fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs:
3733

3834
bb1: {
3935
_10 = move _2; // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
40-
nop; // scope 0 at $DIR/generator-tiny.rs:20:13: 20:15
41-
(((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6 {u8, HasDrop, ()}])) as variant#3).0: HasDrop) = HasDrop; // scope 0 at $DIR/generator-tiny.rs:20:18: 20:25
36+
StorageLive(_3); // scope 0 at $DIR/generator-tiny.rs:20:13: 20:15
4237
StorageLive(_4); // scope 1 at $DIR/generator-tiny.rs:21:9: 24:10
4338
goto -> bb2; // scope 1 at $DIR/generator-tiny.rs:21:9: 24:10
4439
}
4540

4641
bb2: {
4742
StorageLive(_6); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
4843
StorageLive(_7); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
49-
_7 = (); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
5044
_0 = std::ops::GeneratorState::<(), ()>::Yielded(move _7); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
5145
discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6 {u8, HasDrop, ()}]))) = 3; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
5246
return; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
@@ -78,6 +72,7 @@ fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs:
7872
}
7973

8074
bb5: {
75+
StorageLive(_3); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
8176
StorageLive(_4); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
8277
StorageLive(_6); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
8378
StorageLive(_7); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6

‎src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,15 @@ fn foo(_1: T, _2: i32) -> i32 {
2121

2222
bb0: {
2323
StorageLive(_3); // scope 0 at $DIR/inline-closure.rs:11:9: 11:10
24-
_3 = [closure@foo::<T>::{{closure}}#0]; // scope 0 at $DIR/inline-closure.rs:11:13: 11:24
25-
// closure
26-
// + def_id: DefId(0:6 ~ inline_closure[317d]::foo[0]::{{closure}}[0])
27-
// + substs: [
28-
// T,
29-
// i8,
30-
// extern "rust-call" fn((i32, i32)) -> i32,
31-
// (),
32-
// ]
3324
StorageLive(_4); // scope 1 at $DIR/inline-closure.rs:12:5: 12:6
3425
_4 = &_3; // scope 1 at $DIR/inline-closure.rs:12:5: 12:6
3526
StorageLive(_5); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12
3627
StorageLive(_6); // scope 1 at $DIR/inline-closure.rs:12:7: 12:8
3728
_6 = _2; // scope 1 at $DIR/inline-closure.rs:12:7: 12:8
3829
StorageLive(_7); // scope 1 at $DIR/inline-closure.rs:12:10: 12:11
3930
_7 = _2; // scope 1 at $DIR/inline-closure.rs:12:10: 12:11
40-
_5 = (move _6, move _7); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12
31+
(_5.0: i32) = move _6; // scope 1 at $DIR/inline-closure.rs:12:5: 12:12
32+
(_5.1: i32) = move _7; // scope 1 at $DIR/inline-closure.rs:12:5: 12:12
4133
_8 = move (_5.0: i32); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12
4234
_9 = move (_5.1: i32); // scope 1 at $DIR/inline-closure.rs:12:5: 12:12
4335
_0 = _8; // scope 2 at $DIR/inline-closure.rs:11:22: 11:24

‎src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,15 @@ fn foo(_1: T, _2: &i32) -> i32 {
2424

2525
bb0: {
2626
StorageLive(_3); // scope 0 at $DIR/inline-closure-borrows-arg.rs:12:9: 12:10
27-
_3 = [closure@foo::<T>::{{closure}}#0]; // scope 0 at $DIR/inline-closure-borrows-arg.rs:12:13: 15:6
28-
// closure
29-
// + def_id: DefId(0:6 ~ inline_closure_borrows_arg[317d]::foo[0]::{{closure}}[0])
30-
// + substs: [
31-
// T,
32-
// i8,
33-
// for<'r, 's> extern "rust-call" fn((&'r i32, &'s i32)) -> i32,
34-
// (),
35-
// ]
3627
StorageLive(_4); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6
3728
_4 = &_3; // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6
3829
StorageLive(_5); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
3930
StorageLive(_6); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8
4031
_6 = &(*_2); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8
4132
StorageLive(_7); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11
4233
_7 = &(*_2); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11
43-
_5 = (move _6, move _7); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
34+
(_5.0: &i32) = move _6; // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
35+
(_5.1: &i32) = move _7; // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
4436
_8 = move (_5.0: &i32); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
4537
_9 = move (_5.1: &i32); // scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12
4638
_0 = (*_8); // scope 3 at $DIR/inline-closure-borrows-arg.rs:14:9: 14:18

‎src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,16 @@ fn foo(_1: T, _2: i32) -> (i32, T) {
2828
_4 = &_2; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
2929
StorageLive(_5); // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
3030
_5 = &_1; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
31-
_3 = [closure@foo::<T>::{{closure}}#0] { q: move _4, t: move _5 }; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
32-
// closure
33-
// + def_id: DefId(0:6 ~ inline_closure_captures[317d]::foo[0]::{{closure}}[0])
34-
// + substs: [
35-
// T,
36-
// i8,
37-
// extern "rust-call" fn((i32,)) -> (i32, T),
38-
// (&i32, &T),
39-
// ]
31+
(_3.0: &i32) = move _4; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
32+
(_3.1: &T) = move _5; // scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24
4033
StorageDead(_5); // scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24
4134
StorageDead(_4); // scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24
4235
StorageLive(_6); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6
4336
_6 = &_3; // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6
4437
StorageLive(_7); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
4538
StorageLive(_8); // scope 1 at $DIR/inline-closure-captures.rs:12:7: 12:8
4639
_8 = _2; // scope 1 at $DIR/inline-closure-captures.rs:12:7: 12:8
47-
_7 = (move _8,); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
40+
(_7.0: i32) = move _8; // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
4841
_11 = move (_7.0: i32); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
4942
StorageLive(_9); // scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20
5043
_9 = (*((*_6).0: &i32)); // scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20

‎src/test/mir-opt/issue_73223.main.PreCodegen.diff.32bit

Lines changed: 79 additions & 82 deletions
Large diffs are not rendered by default.

‎src/test/mir-opt/issue_73223.main.PreCodegen.diff.64bit

Lines changed: 79 additions & 82 deletions
Large diffs are not rendered by default.

‎src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff.32bit

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,20 @@
165165
StorageLive(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
166166
_17 = (*_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
167167
StorageLive(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
168-
_18 = (*_14); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
169-
_16 = Eq(move _17, move _18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
168+
_18 = const 1_i32; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
169+
// ty::Const
170+
// + ty: i32
171+
// + val: Value(Scalar(0x00000001))
172+
// mir::Constant
173+
// + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL
174+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
175+
_16 = Eq(move _17, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
176+
// ty::Const
177+
// + ty: i32
178+
// + val: Value(Scalar(0x00000001))
179+
// mir::Constant
180+
// + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL
181+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
170182
StorageDead(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
171183
StorageDead(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
172184
_15 = Not(move _16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL

‎src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff.64bit

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,20 @@
165165
StorageLive(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
166166
_17 = (*_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
167167
StorageLive(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
168-
_18 = (*_14); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
169-
_16 = Eq(move _17, move _18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
168+
_18 = const 1_i32; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
169+
// ty::Const
170+
// + ty: i32
171+
// + val: Value(Scalar(0x00000001))
172+
// mir::Constant
173+
// + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL
174+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
175+
_16 = Eq(move _17, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
176+
// ty::Const
177+
// + ty: i32
178+
// + val: Value(Scalar(0x00000001))
179+
// mir::Constant
180+
// + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL
181+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
170182
StorageDead(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
171183
StorageDead(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
172184
_15 = Not(move _16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL

‎src/test/mir-opt/simplify_arm_identity.main.SimplifyArmIdentity.diff.32bit

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@
3939
}
4040

4141
bb1: {
42-
_2 = const Dst::Foo(0_u8); // scope 1 at $DIR/simplify-arm-identity.rs:21:21: 21:32
42+
((_2 as Foo).0: u8) = const 0_u8; // scope 1 at $DIR/simplify-arm-identity.rs:21:21: 21:32
4343
// ty::Const
44-
// + ty: Dst
44+
// + ty: u8
4545
// + val: Value(Scalar(0x00))
4646
// mir::Constant
47-
// + span: $DIR/simplify-arm-identity.rs:21:21: 21:32
48-
// + literal: Const { ty: Dst, val: Value(Scalar(0x00)) }
47+
// + span: $DIR/simplify-arm-identity.rs:21:30: 21:31
48+
// + literal: Const { ty: u8, val: Value(Scalar(0x00)) }
49+
discriminant(_2) = 0; // scope 1 at $DIR/simplify-arm-identity.rs:21:21: 21:32
4950
goto -> bb4; // scope 1 at $DIR/simplify-arm-identity.rs:19:18: 22:6
5051
}
5152

‎src/test/mir-opt/simplify_arm_identity.main.SimplifyArmIdentity.diff.64bit

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@
3939
}
4040

4141
bb1: {
42-
_2 = const Dst::Foo(0_u8); // scope 1 at $DIR/simplify-arm-identity.rs:21:21: 21:32
42+
((_2 as Foo).0: u8) = const 0_u8; // scope 1 at $DIR/simplify-arm-identity.rs:21:21: 21:32
4343
// ty::Const
44-
// + ty: Dst
44+
// + ty: u8
4545
// + val: Value(Scalar(0x00))
4646
// mir::Constant
47-
// + span: $DIR/simplify-arm-identity.rs:21:21: 21:32
48-
// + literal: Const { ty: Dst, val: Value(Scalar(0x00)) }
47+
// + span: $DIR/simplify-arm-identity.rs:21:30: 21:31
48+
// + literal: Const { ty: u8, val: Value(Scalar(0x00)) }
49+
discriminant(_2) = 0; // scope 1 at $DIR/simplify-arm-identity.rs:21:21: 21:32
4950
goto -> bb4; // scope 1 at $DIR/simplify-arm-identity.rs:19:18: 22:6
5051
}
5152

‎src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,58 +22,44 @@
2222
bb0: {
2323
- StorageLive(_1); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28
2424
- StorageLive(_2); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23
25-
- _2 = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23
25+
- StorageLive(_3); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27
26+
- (_1.0: ()) = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28
2627
+ StorageLive(_1); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22
2728
+ _1 = const use_zst(const ((), ())) -> bb1; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22
2829
// ty::Const
2930
- // + ty: ()
3031
- // + val: Value(Scalar(<ZST>))
3132
- // mir::Constant
32-
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23
33+
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28
3334
- // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
34-
- StorageLive(_3); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27
35-
- _3 = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27
35+
- (_1.1: ()) = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28
3636
- // ty::Const
3737
- // + ty: ()
3838
- // + val: Value(Scalar(<ZST>))
3939
- // mir::Constant
40-
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27
41-
- // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
42-
- _1 = const ((), ()); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28
43-
- // ty::Const
44-
- // + ty: ((), ())
45-
- // + val: Value(Scalar(<ZST>))
46-
- // mir::Constant
4740
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28
48-
- // + literal: Const { ty: ((), ()), val: Value(Scalar(<ZST>)) }
41+
- // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
4942
- StorageDead(_3); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:27: 13:28
5043
- StorageDead(_2); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:27: 13:28
5144
- StorageDead(_1); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:28: 13:29
5245
- StorageLive(_4); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22
5346
- StorageLive(_5); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21
5447
- StorageLive(_6); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16
55-
- _6 = const (); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16
56-
- // ty::Const
57-
- // + ty: ()
58-
- // + val: Value(Scalar(<ZST>))
59-
- // mir::Constant
60-
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16
61-
- // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
6248
- StorageLive(_7); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20
63-
- _7 = const (); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20
49+
- (_5.0: ()) = const (); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21
6450
- // ty::Const
6551
- // + ty: ()
6652
- // + val: Value(Scalar(<ZST>))
6753
- // mir::Constant
68-
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20
54+
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21
6955
- // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
70-
- _5 = const ((), ()); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21
56+
- (_5.1: ()) = const (); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21
7157
- // ty::Const
72-
- // + ty: ((), ())
58+
- // + ty: ()
7359
- // + val: Value(Scalar(<ZST>))
7460
- // mir::Constant
7561
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21
76-
- // + literal: Const { ty: ((), ()), val: Value(Scalar(<ZST>)) }
62+
- // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
7763
- StorageDead(_7); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:20: 14:21
7864
- StorageDead(_6); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:20: 14:21
7965
- _4 = const use_zst(const ((), ())) -> bb1; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22
@@ -98,16 +84,16 @@
9884
- StorageLive(_9); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:34
9985
- StorageLive(_10); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30
10086
- StorageLive(_11); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28
101-
- _11 = const Temp { x: 40_u8 }; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28
87+
- (_11.0: u8) = const 40_u8; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28
10288
+ StorageDead(_1); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:22: 14:23
10389
+ StorageLive(_2); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35
10490
+ _2 = const use_u8(const 42_u8) -> bb2; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35
10591
// ty::Const
106-
- // + ty: Temp
92+
- // + ty: u8
10793
- // + val: Value(Scalar(0x28))
10894
- // mir::Constant
109-
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28
110-
- // + literal: Const { ty: Temp, val: Value(Scalar(0x28)) }
95+
- // + span: $DIR/simplify-locals-removes-unused-consts.rs:16:23: 16:25
96+
- // + literal: Const { ty: u8, val: Value(Scalar(0x28)) }
11197
- _10 = const 40_u8; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30
11298
- // ty::Const
11399
- // + ty: u8

‎src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.diff.32bit

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@
3939
}
4040

4141
bb2: {
42-
_0 = const std::option::Option::<std::boxed::Box<()>>::None; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:17: 3:21
43-
// ty::Const
44-
// + ty: std::option::Option<std::boxed::Box<()>>
45-
// + val: Value(Scalar(0x00000000))
46-
// mir::Constant
47-
// + span: $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:17: 3:21
48-
// + literal: Const { ty: std::option::Option<std::boxed::Box<()>>, val: Value(Scalar(0x00000000)) }
42+
discriminant(_0) = 0; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:17: 3:21
4943
goto -> bb3; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:2:5: 5:6
5044
}
5145

‎src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.diff.64bit

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@
3939
}
4040

4141
bb2: {
42-
_0 = const std::option::Option::<std::boxed::Box<()>>::None; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:17: 3:21
43-
// ty::Const
44-
// + ty: std::option::Option<std::boxed::Box<()>>
45-
// + val: Value(Scalar(0x0000000000000000))
46-
// mir::Constant
47-
// + span: $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:17: 3:21
48-
// + literal: Const { ty: std::option::Option<std::boxed::Box<()>>, val: Value(Scalar(0x0000000000000000)) }
42+
discriminant(_0) = 0; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:17: 3:21
4943
goto -> bb3; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:2:5: 5:6
5044
}
5145

‎src/test/mir-opt/uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() -> () {
1515
bb0: {
1616
StorageLive(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6
1717
StorageLive(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
18-
_2 = Test1::C; // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
18+
discriminant(_2) = 2; // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
1919
_3 = discriminant(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20
2020
StorageLive(_5); // scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24
2121
_5 = const "C"; // scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24
@@ -31,7 +31,7 @@ fn main() -> () {
3131
StorageDead(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:24:6: 24:7
3232
StorageLive(_6); // scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6
3333
StorageLive(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
34-
_7 = Test2::D; // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
34+
discriminant(_7) = 0; // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
3535
_8 = discriminant(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17
3636
switchInt(move _8) -> [4_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17
3737
}

‎src/test/mir-opt/uninhabited_enum_branching.main.UninhabitedEnumBranching.diff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
bb0: {
1717
StorageLive(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6
1818
StorageLive(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
19-
_2 = Test1::C; // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
19+
discriminant(_2) = 2; // scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19
2020
_3 = discriminant(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20
2121
- switchInt(move _3) -> [0_isize: bb2, 1_isize: bb3, otherwise: bb1]; // scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20
2222
+ switchInt(move _3) -> bb1; // scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20
@@ -66,7 +66,7 @@
6666
StorageDead(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:24:6: 24:7
6767
StorageLive(_6); // scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6
6868
StorageLive(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
69-
_7 = Test2::D; // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
69+
discriminant(_7) = 0; // scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19
7070
_8 = discriminant(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17
7171
switchInt(move _8) -> [4_isize: bb6, otherwise: bb5]; // scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17
7272
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
- // MIR for `change_loop_body` before ConstProp
2+
+ // MIR for `change_loop_body` after ConstProp
3+
4+
fn change_loop_body() -> () {
5+
let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:5:27: 5:27
6+
let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
7+
let mut _2: (); // in scope 0 at $DIR/while_let_loops.rs:5:1: 11:2
8+
let mut _3: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:7:28: 7:32
9+
let mut _4: isize; // in scope 0 at $DIR/while_let_loops.rs:7:15: 7:25
10+
let mut _5: !; // in scope 0 at $DIR/while_let_loops.rs:7:33: 10:6
11+
let mut _6: !; // in scope 0 at $DIR/while_let_loops.rs:7:5: 10:6
12+
scope 1 {
13+
debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:6:9: 6:15
14+
}
15+
16+
bb0: {
17+
StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
18+
_1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:6:18: 6:19
19+
// ty::Const
20+
// + ty: i32
21+
// + val: Value(Scalar(0x00000000))
22+
// mir::Constant
23+
// + span: $DIR/while_let_loops.rs:6:18: 6:19
24+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
25+
StorageLive(_3); // scope 1 at $DIR/while_let_loops.rs:7:28: 7:32
26+
discriminant(_3) = 0; // scope 1 at $DIR/while_let_loops.rs:7:28: 7:32
27+
- _4 = discriminant(_3); // scope 1 at $DIR/while_let_loops.rs:7:15: 7:25
28+
- switchInt(move _4) -> [1_isize: bb2, otherwise: bb1]; // scope 1 at $DIR/while_let_loops.rs:7:15: 7:25
29+
+ _4 = const 0_isize; // scope 1 at $DIR/while_let_loops.rs:7:15: 7:25
30+
+ // ty::Const
31+
+ // + ty: isize
32+
+ // + val: Value(Scalar(0x00000000))
33+
+ // mir::Constant
34+
+ // + span: $DIR/while_let_loops.rs:7:15: 7:25
35+
+ // + literal: Const { ty: isize, val: Value(Scalar(0x00000000)) }
36+
+ switchInt(const 0_isize) -> [1_isize: bb2, otherwise: bb1]; // scope 1 at $DIR/while_let_loops.rs:7:15: 7:25
37+
+ // ty::Const
38+
+ // + ty: isize
39+
+ // + val: Value(Scalar(0x00000000))
40+
+ // mir::Constant
41+
+ // + span: $DIR/while_let_loops.rs:7:15: 7:25
42+
+ // + literal: Const { ty: isize, val: Value(Scalar(0x00000000)) }
43+
}
44+
45+
bb1: {
46+
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6
47+
// ty::Const
48+
// + ty: ()
49+
// + val: Value(Scalar(<ZST>))
50+
// mir::Constant
51+
// + span: $DIR/while_let_loops.rs:7:5: 10:6
52+
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
53+
goto -> bb4; // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6
54+
}
55+
56+
bb2: {
57+
switchInt(((_3 as Some).0: u32)) -> [0_u32: bb3, otherwise: bb1]; // scope 1 at $DIR/while_let_loops.rs:7:20: 7:24
58+
}
59+
60+
bb3: {
61+
_1 = const 1_i32; // scope 1 at $DIR/while_let_loops.rs:8:9: 8:15
62+
// ty::Const
63+
// + ty: i32
64+
// + val: Value(Scalar(0x00000001))
65+
// mir::Constant
66+
// + span: $DIR/while_let_loops.rs:8:14: 8:15
67+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
68+
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:9:9: 9:14
69+
// ty::Const
70+
// + ty: ()
71+
// + val: Value(Scalar(<ZST>))
72+
// mir::Constant
73+
// + span: $DIR/while_let_loops.rs:9:9: 9:14
74+
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
75+
goto -> bb4; // scope 1 at $DIR/while_let_loops.rs:9:9: 9:14
76+
}
77+
78+
bb4: {
79+
StorageDead(_3); // scope 1 at $DIR/while_let_loops.rs:10:5: 10:6
80+
StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:11:1: 11:2
81+
return; // scope 0 at $DIR/while_let_loops.rs:11:2: 11:2
82+
}
83+
}
84+
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
- // MIR for `change_loop_body` before ConstProp
2+
+ // MIR for `change_loop_body` after ConstProp
3+
4+
fn change_loop_body() -> () {
5+
let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:5:27: 5:27
6+
let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
7+
let mut _2: (); // in scope 0 at $DIR/while_let_loops.rs:5:1: 11:2
8+
let mut _3: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:7:28: 7:32
9+
let mut _4: isize; // in scope 0 at $DIR/while_let_loops.rs:7:15: 7:25
10+
let mut _5: !; // in scope 0 at $DIR/while_let_loops.rs:7:33: 10:6
11+
let mut _6: !; // in scope 0 at $DIR/while_let_loops.rs:7:5: 10:6
12+
scope 1 {
13+
debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:6:9: 6:15
14+
}
15+
16+
bb0: {
17+
StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
18+
_1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:6:18: 6:19
19+
// ty::Const
20+
// + ty: i32
21+
// + val: Value(Scalar(0x00000000))
22+
// mir::Constant
23+
// + span: $DIR/while_let_loops.rs:6:18: 6:19
24+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
25+
StorageLive(_3); // scope 1 at $DIR/while_let_loops.rs:7:28: 7:32
26+
discriminant(_3) = 0; // scope 1 at $DIR/while_let_loops.rs:7:28: 7:32
27+
- _4 = discriminant(_3); // scope 1 at $DIR/while_let_loops.rs:7:15: 7:25
28+
- switchInt(move _4) -> [1_isize: bb2, otherwise: bb1]; // scope 1 at $DIR/while_let_loops.rs:7:15: 7:25
29+
+ _4 = const 0_isize; // scope 1 at $DIR/while_let_loops.rs:7:15: 7:25
30+
+ // ty::Const
31+
+ // + ty: isize
32+
+ // + val: Value(Scalar(0x0000000000000000))
33+
+ // mir::Constant
34+
+ // + span: $DIR/while_let_loops.rs:7:15: 7:25
35+
+ // + literal: Const { ty: isize, val: Value(Scalar(0x0000000000000000)) }
36+
+ switchInt(const 0_isize) -> [1_isize: bb2, otherwise: bb1]; // scope 1 at $DIR/while_let_loops.rs:7:15: 7:25
37+
+ // ty::Const
38+
+ // + ty: isize
39+
+ // + val: Value(Scalar(0x0000000000000000))
40+
+ // mir::Constant
41+
+ // + span: $DIR/while_let_loops.rs:7:15: 7:25
42+
+ // + literal: Const { ty: isize, val: Value(Scalar(0x0000000000000000)) }
43+
}
44+
45+
bb1: {
46+
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6
47+
// ty::Const
48+
// + ty: ()
49+
// + val: Value(Scalar(<ZST>))
50+
// mir::Constant
51+
// + span: $DIR/while_let_loops.rs:7:5: 10:6
52+
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
53+
goto -> bb4; // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6
54+
}
55+
56+
bb2: {
57+
switchInt(((_3 as Some).0: u32)) -> [0_u32: bb3, otherwise: bb1]; // scope 1 at $DIR/while_let_loops.rs:7:20: 7:24
58+
}
59+
60+
bb3: {
61+
_1 = const 1_i32; // scope 1 at $DIR/while_let_loops.rs:8:9: 8:15
62+
// ty::Const
63+
// + ty: i32
64+
// + val: Value(Scalar(0x00000001))
65+
// mir::Constant
66+
// + span: $DIR/while_let_loops.rs:8:14: 8:15
67+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
68+
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:9:9: 9:14
69+
// ty::Const
70+
// + ty: ()
71+
// + val: Value(Scalar(<ZST>))
72+
// mir::Constant
73+
// + span: $DIR/while_let_loops.rs:9:9: 9:14
74+
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
75+
goto -> bb4; // scope 1 at $DIR/while_let_loops.rs:9:9: 9:14
76+
}
77+
78+
bb4: {
79+
StorageDead(_3); // scope 1 at $DIR/while_let_loops.rs:10:5: 10:6
80+
StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:11:1: 11:2
81+
return; // scope 0 at $DIR/while_let_loops.rs:11:2: 11:2
82+
}
83+
}
84+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// MIR for `change_loop_body` after PreCodegen
2+
3+
fn change_loop_body() -> () {
4+
let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:5:27: 5:27
5+
let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
6+
let mut _2: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:7:28: 7:32
7+
scope 1 {
8+
debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:6:9: 6:15
9+
}
10+
11+
bb0: {
12+
StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
13+
_1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:6:18: 6:19
14+
// ty::Const
15+
// + ty: i32
16+
// + val: Value(Scalar(0x00000000))
17+
// mir::Constant
18+
// + span: $DIR/while_let_loops.rs:6:18: 6:19
19+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
20+
StorageLive(_2); // scope 1 at $DIR/while_let_loops.rs:7:28: 7:32
21+
discriminant(_2) = 0; // scope 1 at $DIR/while_let_loops.rs:7:28: 7:32
22+
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6
23+
// ty::Const
24+
// + ty: ()
25+
// + val: Value(Scalar(<ZST>))
26+
// mir::Constant
27+
// + span: $DIR/while_let_loops.rs:7:5: 10:6
28+
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
29+
StorageDead(_2); // scope 1 at $DIR/while_let_loops.rs:10:5: 10:6
30+
StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:11:1: 11:2
31+
return; // scope 0 at $DIR/while_let_loops.rs:11:2: 11:2
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// MIR for `change_loop_body` after PreCodegen
2+
3+
fn change_loop_body() -> () {
4+
let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:5:27: 5:27
5+
let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
6+
let mut _2: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:7:28: 7:32
7+
scope 1 {
8+
debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:6:9: 6:15
9+
}
10+
11+
bb0: {
12+
StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:6:9: 6:15
13+
_1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:6:18: 6:19
14+
// ty::Const
15+
// + ty: i32
16+
// + val: Value(Scalar(0x00000000))
17+
// mir::Constant
18+
// + span: $DIR/while_let_loops.rs:6:18: 6:19
19+
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
20+
StorageLive(_2); // scope 1 at $DIR/while_let_loops.rs:7:28: 7:32
21+
discriminant(_2) = 0; // scope 1 at $DIR/while_let_loops.rs:7:28: 7:32
22+
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:7:5: 10:6
23+
// ty::Const
24+
// + ty: ()
25+
// + val: Value(Scalar(<ZST>))
26+
// mir::Constant
27+
// + span: $DIR/while_let_loops.rs:7:5: 10:6
28+
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
29+
StorageDead(_2); // scope 1 at $DIR/while_let_loops.rs:10:5: 10:6
30+
StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:11:1: 11:2
31+
return; // scope 0 at $DIR/while_let_loops.rs:11:2: 11:2
32+
}
33+
}

‎src/test/mir-opt/while_let_loops.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// EMIT_MIR while_let_loops.change_loop_body.ConstProp.diff
2+
// EMIT_MIR while_let_loops.change_loop_body.PreCodegen.after.mir
3+
// EMIT_MIR_FOR_EACH_BIT_WIDTH
4+
5+
pub fn change_loop_body() {
6+
let mut _x = 0;
7+
while let Some(0u32) = None {
8+
_x = 1;
9+
break;
10+
}
11+
}
12+
13+
fn main() {
14+
change_loop_body();
15+
}

0 commit comments

Comments
 (0)
This repository has been archived.