Skip to content

Commit bed69c6

Browse files
committedFeb 5, 2021
Revert "Use record_operands_moved more aggresively"
This reverts commit 7f3e855.
·
1.88.01.51.0
1 parent a71a819 commit bed69c6

11 files changed

+190
-114
lines changed
 

‎compiler/rustc_mir_build/src/build/expr/as_rvalue.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ use rustc_middle::mir::*;
1212
use rustc_middle::ty::{self, Ty, UpvarSubsts};
1313
use rustc_span::Span;
1414

15-
use std::slice;
16-
1715
impl<'a, 'tcx> Builder<'a, 'tcx> {
1816
/// Returns an rvalue suitable for use until the end of the current
1917
/// scope expression.
@@ -120,9 +118,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
120118
block =
121119
this.into(this.hir.tcx().mk_place_deref(Place::from(result)), block, value)
122120
);
123-
let result_operand = Operand::Move(Place::from(result));
124-
this.record_operands_moved(slice::from_ref(&result_operand));
125-
block.and(Rvalue::Use(result_operand))
121+
block.and(Rvalue::Use(Operand::Move(Place::from(result))))
126122
}
127123
ExprKind::Cast { source } => {
128124
let source = unpack!(block = this.as_operand(block, scope, source));
@@ -166,7 +162,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
166162
.map(|f| unpack!(block = this.as_operand(block, scope, f)))
167163
.collect();
168164

169-
this.record_operands_moved(&fields);
170165
block.and(Rvalue::Aggregate(box AggregateKind::Array(el_ty), fields))
171166
}
172167
ExprKind::Tuple { fields } => {
@@ -177,7 +172,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
177172
.map(|f| unpack!(block = this.as_operand(block, scope, f)))
178173
.collect();
179174

180-
this.record_operands_moved(&fields);
181175
block.and(Rvalue::Aggregate(box AggregateKind::Tuple, fields))
182176
}
183177
ExprKind::Closure { closure_id, substs, upvars, movability } => {
@@ -229,7 +223,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
229223
}
230224
UpvarSubsts::Closure(substs) => box AggregateKind::Closure(closure_id, substs),
231225
};
232-
this.record_operands_moved(&operands);
233226
block.and(Rvalue::Aggregate(result, operands))
234227
}
235228
ExprKind::Assign { .. } | ExprKind::AssignOp { .. } => {

‎compiler/rustc_mir_build/src/build/expr/into.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ use rustc_hir as hir;
1010
use rustc_middle::mir::*;
1111
use rustc_middle::ty::CanonicalUserTypeAnnotation;
1212

13-
use std::slice;
14-
1513
impl<'a, 'tcx> Builder<'a, 'tcx> {
1614
/// Compile `expr`, storing the result into `destination`, which
1715
/// is assumed to be uninitialized.
@@ -277,6 +275,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
277275
let fields: Vec<_> = if let Some(FruInfo { base, field_types }) = base {
278276
let place_builder = unpack!(block = this.as_place_builder(block, base));
279277

278+
280279
// MIR does not natively support FRU, so for each
281280
// base-supplied field, generate an operand that
282281
// reads it from the base.
@@ -314,7 +313,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
314313
user_ty,
315314
active_field_index,
316315
);
317-
this.record_operands_moved(&fields);
318316
this.cfg.push_assign(
319317
block,
320318
source_info,
@@ -441,7 +439,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
441439
let scope = this.local_scope();
442440
let value = unpack!(block = this.as_operand(block, Some(scope), value));
443441
let resume = this.cfg.start_new_block();
444-
this.record_operands_moved(slice::from_ref(&value));
445442
this.cfg.terminate(
446443
block,
447444
source_info,

‎compiler/rustc_mir_build/src/build/expr/stmt.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
33
use crate::thir::*;
44
use rustc_middle::middle::region;
55
use rustc_middle::mir::*;
6-
use std::slice;
76

87
impl<'a, 'tcx> Builder<'a, 'tcx> {
98
/// Builds a block of MIR statements to evaluate the THIR `expr`.
@@ -47,7 +46,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
4746
if this.hir.needs_drop(lhs.ty) {
4847
let rhs = unpack!(block = this.as_local_operand(block, rhs));
4948
let lhs = unpack!(block = this.as_place(block, lhs));
50-
this.record_operands_moved(slice::from_ref(&rhs));
5149
unpack!(block = this.build_drop_and_replace(block, lhs_span, lhs, rhs));
5250
} else {
5351
let rhs = unpack!(block = this.as_local_rvalue(block, rhs));

‎compiler/rustc_mir_build/src/build/scope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ impl<'tcx> DropTreeBuilder<'tcx> for Unwind {
13521352
| TerminatorKind::Yield { .. }
13531353
| TerminatorKind::GeneratorDrop
13541354
| TerminatorKind::FalseEdge { .. }
1355-
| TerminatorKind::InlineAsm { .. } => {
1355+
| TerminatorKind::InlineAsm {.. } => {
13561356
span_bug!(term.source_info.span, "cannot unwind from {:?}", term.kind)
13571357
}
13581358
}

‎src/test/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,36 +41,44 @@ fn main() -> () {
4141
StorageLive(_5); // scope 3 at $DIR/basic_assignment.rs:19:9: 19:15
4242
StorageLive(_6); // scope 4 at $DIR/basic_assignment.rs:23:14: 23:20
4343
_6 = move _4; // scope 4 at $DIR/basic_assignment.rs:23:14: 23:20
44-
replace(_5 <- move _6) -> [return: bb1, unwind: bb4]; // scope 4 at $DIR/basic_assignment.rs:23:5: 23:11
44+
replace(_5 <- move _6) -> [return: bb1, unwind: bb5]; // scope 4 at $DIR/basic_assignment.rs:23:5: 23:11
4545
}
4646

4747
bb1: {
48+
drop(_6) -> [return: bb2, unwind: bb6]; // scope 4 at $DIR/basic_assignment.rs:23:19: 23:20
49+
}
50+
51+
bb2: {
4852
StorageDead(_6); // scope 4 at $DIR/basic_assignment.rs:23:19: 23:20
4953
_0 = const (); // scope 0 at $DIR/basic_assignment.rs:10:11: 24:2
50-
drop(_5) -> [return: bb2, unwind: bb5]; // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2
54+
drop(_5) -> [return: bb3, unwind: bb7]; // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2
5155
}
5256

53-
bb2: {
57+
bb3: {
5458
StorageDead(_5); // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2
55-
drop(_4) -> [return: bb3, unwind: bb6]; // scope 2 at $DIR/basic_assignment.rs:24:1: 24:2
59+
drop(_4) -> [return: bb4, unwind: bb8]; // scope 2 at $DIR/basic_assignment.rs:24:1: 24:2
5660
}
5761

58-
bb3: {
62+
bb4: {
5963
StorageDead(_4); // scope 2 at $DIR/basic_assignment.rs:24:1: 24:2
6064
StorageDead(_2); // scope 1 at $DIR/basic_assignment.rs:24:1: 24:2
6165
StorageDead(_1); // scope 0 at $DIR/basic_assignment.rs:24:1: 24:2
6266
return; // scope 0 at $DIR/basic_assignment.rs:24:2: 24:2
6367
}
6468

65-
bb4 (cleanup): {
66-
drop(_5) -> bb5; // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2
67-
}
68-
6969
bb5 (cleanup): {
70-
drop(_4) -> bb6; // scope 2 at $DIR/basic_assignment.rs:24:1: 24:2
70+
drop(_6) -> bb6; // scope 4 at $DIR/basic_assignment.rs:23:19: 23:20
7171
}
7272

7373
bb6 (cleanup): {
74+
drop(_5) -> bb7; // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2
75+
}
76+
77+
bb7 (cleanup): {
78+
drop(_4) -> bb8; // scope 2 at $DIR/basic_assignment.rs:24:1: 24:2
79+
}
80+
81+
bb8 (cleanup): {
7482
resume; // scope 0 at $DIR/basic_assignment.rs:10:1: 24:2
7583
}
7684
}

‎src/test/mir-opt/box_expr.main.ElaborateDrops.before.mir

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,49 @@ fn main() -> () {
1414
StorageLive(_1); // scope 0 at $DIR/box_expr.rs:7:9: 7:10
1515
StorageLive(_2); // scope 0 at $DIR/box_expr.rs:7:13: 7:25
1616
_2 = Box(S); // scope 0 at $DIR/box_expr.rs:7:13: 7:25
17-
(*_2) = S::new() -> [return: bb1, unwind: bb5]; // scope 0 at $DIR/box_expr.rs:7:17: 7:25
17+
(*_2) = S::new() -> [return: bb1, unwind: bb6]; // scope 0 at $DIR/box_expr.rs:7:17: 7:25
1818
// mir::Constant
1919
// + span: $DIR/box_expr.rs:7:17: 7:23
2020
// + literal: Const { ty: fn() -> S {S::new}, val: Value(Scalar(<ZST>)) }
2121
}
2222

2323
bb1: {
2424
_1 = move _2; // scope 0 at $DIR/box_expr.rs:7:13: 7:25
25+
drop(_2) -> bb2; // scope 0 at $DIR/box_expr.rs:7:24: 7:25
26+
}
27+
28+
bb2: {
2529
StorageDead(_2); // scope 0 at $DIR/box_expr.rs:7:24: 7:25
2630
StorageLive(_3); // scope 1 at $DIR/box_expr.rs:8:5: 8:12
2731
StorageLive(_4); // scope 1 at $DIR/box_expr.rs:8:10: 8:11
2832
_4 = move _1; // scope 1 at $DIR/box_expr.rs:8:10: 8:11
29-
_3 = std::mem::drop::<Box<S>>(move _4) -> [return: bb2, unwind: bb4]; // scope 1 at $DIR/box_expr.rs:8:5: 8:12
33+
_3 = std::mem::drop::<Box<S>>(move _4) -> [return: bb3, unwind: bb5]; // scope 1 at $DIR/box_expr.rs:8:5: 8:12
3034
// mir::Constant
3135
// + span: $DIR/box_expr.rs:8:5: 8:9
3236
// + literal: Const { ty: fn(std::boxed::Box<S>) {std::mem::drop::<std::boxed::Box<S>>}, val: Value(Scalar(<ZST>)) }
3337
}
3438

35-
bb2: {
39+
bb3: {
3640
StorageDead(_4); // scope 1 at $DIR/box_expr.rs:8:11: 8:12
3741
StorageDead(_3); // scope 1 at $DIR/box_expr.rs:8:12: 8:13
3842
_0 = const (); // scope 0 at $DIR/box_expr.rs:6:11: 9:2
39-
drop(_1) -> bb3; // scope 0 at $DIR/box_expr.rs:9:1: 9:2
43+
drop(_1) -> bb4; // scope 0 at $DIR/box_expr.rs:9:1: 9:2
4044
}
4145

42-
bb3: {
46+
bb4: {
4347
StorageDead(_1); // scope 0 at $DIR/box_expr.rs:9:1: 9:2
4448
return; // scope 0 at $DIR/box_expr.rs:9:2: 9:2
4549
}
4650

47-
bb4 (cleanup): {
48-
drop(_1) -> bb6; // scope 0 at $DIR/box_expr.rs:9:1: 9:2
49-
}
50-
5151
bb5 (cleanup): {
52-
drop(_2) -> bb6; // scope 0 at $DIR/box_expr.rs:7:24: 7:25
52+
drop(_1) -> bb7; // scope 0 at $DIR/box_expr.rs:9:1: 9:2
5353
}
5454

5555
bb6 (cleanup): {
56+
drop(_2) -> bb7; // scope 0 at $DIR/box_expr.rs:7:24: 7:25
57+
}
58+
59+
bb7 (cleanup): {
5660
resume; // scope 0 at $DIR/box_expr.rs:6:1: 9:2
5761
}
5862
}

‎src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn test() -> () {
2525
StorageLive(_3); // scope 2 at $DIR/issue-41110.rs:17:5: 17:12
2626
StorageLive(_4); // scope 2 at $DIR/issue-41110.rs:17:10: 17:11
2727
_4 = move _2; // scope 2 at $DIR/issue-41110.rs:17:10: 17:11
28-
_3 = std::mem::drop::<S>(move _4) -> [return: bb1, unwind: bb5]; // scope 2 at $DIR/issue-41110.rs:17:5: 17:12
28+
_3 = std::mem::drop::<S>(move _4) -> [return: bb1, unwind: bb7]; // scope 2 at $DIR/issue-41110.rs:17:5: 17:12
2929
// mir::Constant
3030
// + span: $DIR/issue-41110.rs:17:5: 17:9
3131
// + literal: Const { ty: fn(S) {std::mem::drop::<S>}, val: Value(Scalar(<ZST>)) }
@@ -37,53 +37,61 @@ fn test() -> () {
3737
StorageLive(_5); // scope 2 at $DIR/issue-41110.rs:18:9: 18:10
3838
_6 = const false; // scope 2 at $DIR/issue-41110.rs:18:9: 18:10
3939
_5 = move _1; // scope 2 at $DIR/issue-41110.rs:18:9: 18:10
40-
goto -> bb9; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6
40+
goto -> bb11; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6
4141
}
4242

4343
bb2: {
44+
goto -> bb3; // scope 2 at $DIR/issue-41110.rs:18:9: 18:10
45+
}
46+
47+
bb3: {
4448
StorageDead(_5); // scope 2 at $DIR/issue-41110.rs:18:9: 18:10
4549
_0 = const (); // scope 0 at $DIR/issue-41110.rs:14:15: 19:2
46-
drop(_2) -> [return: bb3, unwind: bb6]; // scope 1 at $DIR/issue-41110.rs:19:1: 19:2
50+
drop(_2) -> [return: bb4, unwind: bb8]; // scope 1 at $DIR/issue-41110.rs:19:1: 19:2
4751
}
4852

49-
bb3: {
53+
bb4: {
5054
StorageDead(_2); // scope 1 at $DIR/issue-41110.rs:19:1: 19:2
51-
goto -> bb4; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2
55+
goto -> bb5; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2
5256
}
5357

54-
bb4: {
58+
bb5: {
5559
_6 = const false; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2
5660
StorageDead(_1); // scope 0 at $DIR/issue-41110.rs:19:1: 19:2
5761
return; // scope 0 at $DIR/issue-41110.rs:19:2: 19:2
5862
}
5963

60-
bb5 (cleanup): {
61-
goto -> bb6; // scope 1 at $DIR/issue-41110.rs:19:1: 19:2
62-
}
63-
6464
bb6 (cleanup): {
65-
goto -> bb11; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2
65+
goto -> bb7; // scope 2 at $DIR/issue-41110.rs:18:9: 18:10
6666
}
6767

6868
bb7 (cleanup): {
69-
resume; // scope 0 at $DIR/issue-41110.rs:14:1: 19:2
69+
goto -> bb8; // scope 1 at $DIR/issue-41110.rs:19:1: 19:2
7070
}
7171

7272
bb8 (cleanup): {
73+
goto -> bb13; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2
74+
}
75+
76+
bb9 (cleanup): {
77+
resume; // scope 0 at $DIR/issue-41110.rs:14:1: 19:2
78+
}
79+
80+
bb10 (cleanup): {
7381
_2 = move _5; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6
74-
goto -> bb5; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6
82+
goto -> bb6; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6
7583
}
7684

77-
bb9: {
85+
bb11: {
7886
_2 = move _5; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6
7987
goto -> bb2; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6
8088
}
8189

82-
bb10 (cleanup): {
83-
drop(_1) -> bb7; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2
90+
bb12 (cleanup): {
91+
drop(_1) -> bb9; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2
8492
}
8593

86-
bb11 (cleanup): {
87-
switchInt(_6) -> [false: bb7, otherwise: bb10]; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2
94+
bb13 (cleanup): {
95+
switchInt(_6) -> [false: bb9, otherwise: bb12]; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2
8896
}
8997
}

‎src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn main() -> () {
2626
_8 = const false; // scope 0 at $DIR/issue-41888.rs:7:9: 7:10
2727
StorageLive(_1); // scope 0 at $DIR/issue-41888.rs:7:9: 7:10
2828
StorageLive(_2); // scope 1 at $DIR/issue-41888.rs:8:8: 8:14
29-
_2 = cond() -> [return: bb1, unwind: bb9]; // scope 1 at $DIR/issue-41888.rs:8:8: 8:14
29+
_2 = cond() -> [return: bb1, unwind: bb11]; // scope 1 at $DIR/issue-41888.rs:8:8: 8:14
3030
// mir::Constant
3131
// + span: $DIR/issue-41888.rs:8:8: 8:12
3232
// + literal: Const { ty: fn() -> bool {cond}, val: Value(Scalar(<ZST>)) }
@@ -42,103 +42,111 @@ fn main() -> () {
4242
_4 = K; // scope 1 at $DIR/issue-41888.rs:9:18: 9:19
4343
_3 = E::F(move _4); // scope 1 at $DIR/issue-41888.rs:9:13: 9:20
4444
StorageDead(_4); // scope 1 at $DIR/issue-41888.rs:9:19: 9:20
45-
goto -> bb12; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10
45+
goto -> bb14; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10
4646
}
4747

4848
bb3: {
4949
_0 = const (); // scope 1 at $DIR/issue-41888.rs:14:6: 14:6
50-
goto -> bb7; // scope 1 at $DIR/issue-41888.rs:8:5: 14:6
50+
goto -> bb8; // scope 1 at $DIR/issue-41888.rs:8:5: 14:6
5151
}
5252

5353
bb4: {
54+
goto -> bb5; // scope 1 at $DIR/issue-41888.rs:9:19: 9:20
55+
}
56+
57+
bb5: {
5458
StorageDead(_3); // scope 1 at $DIR/issue-41888.rs:9:19: 9:20
5559
_5 = discriminant(_1); // scope 1 at $DIR/issue-41888.rs:10:16: 10:24
56-
switchInt(move _5) -> [0_isize: bb6, otherwise: bb5]; // scope 1 at $DIR/issue-41888.rs:10:16: 10:24
60+
switchInt(move _5) -> [0_isize: bb7, otherwise: bb6]; // scope 1 at $DIR/issue-41888.rs:10:16: 10:24
5761
}
5862

59-
bb5: {
63+
bb6: {
6064
_0 = const (); // scope 1 at $DIR/issue-41888.rs:13:10: 13:10
61-
goto -> bb7; // scope 1 at $DIR/issue-41888.rs:10:9: 13:10
65+
goto -> bb8; // scope 1 at $DIR/issue-41888.rs:10:9: 13:10
6266
}
6367

64-
bb6: {
68+
bb7: {
6569
StorageLive(_6); // scope 1 at $DIR/issue-41888.rs:10:21: 10:23
6670
_9 = const false; // scope 1 at $DIR/issue-41888.rs:10:21: 10:23
6771
_6 = move ((_1 as F).0: K); // scope 1 at $DIR/issue-41888.rs:10:21: 10:23
6872
_0 = const (); // scope 2 at $DIR/issue-41888.rs:10:29: 13:10
6973
StorageDead(_6); // scope 1 at $DIR/issue-41888.rs:13:9: 13:10
70-
goto -> bb7; // scope 1 at $DIR/issue-41888.rs:10:9: 13:10
74+
goto -> bb8; // scope 1 at $DIR/issue-41888.rs:10:9: 13:10
7175
}
7276

73-
bb7: {
77+
bb8: {
7478
StorageDead(_2); // scope 1 at $DIR/issue-41888.rs:14:5: 14:6
75-
goto -> bb18; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
79+
goto -> bb20; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
7680
}
7781

78-
bb8: {
82+
bb9: {
7983
_7 = const false; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
8084
_8 = const false; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
8185
_9 = const false; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
8286
StorageDead(_1); // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
8387
return; // scope 0 at $DIR/issue-41888.rs:15:2: 15:2
8488
}
8589

86-
bb9 (cleanup): {
87-
goto -> bb10; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
90+
bb10 (cleanup): {
91+
goto -> bb11; // scope 1 at $DIR/issue-41888.rs:9:19: 9:20
92+
}
93+
94+
bb11 (cleanup): {
95+
goto -> bb12; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
8896
}
8997

90-
bb10 (cleanup): {
98+
bb12 (cleanup): {
9199
resume; // scope 0 at $DIR/issue-41888.rs:6:1: 15:2
92100
}
93101

94-
bb11 (cleanup): {
102+
bb13 (cleanup): {
95103
_7 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10
96104
_8 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10
97105
_9 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10
98106
_1 = move _3; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10
99-
goto -> bb9; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10
107+
goto -> bb10; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10
100108
}
101109

102-
bb12: {
110+
bb14: {
103111
_7 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10
104112
_8 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10
105113
_9 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10
106114
_1 = move _3; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10
107115
goto -> bb4; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10
108116
}
109117

110-
bb13: {
118+
bb15: {
111119
_7 = const false; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
112-
goto -> bb8; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
120+
goto -> bb9; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
113121
}
114122

115-
bb14 (cleanup): {
116-
goto -> bb10; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
123+
bb16 (cleanup): {
124+
goto -> bb12; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
117125
}
118126

119-
bb15: {
120-
drop(_1) -> [return: bb13, unwind: bb10]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
127+
bb17: {
128+
drop(_1) -> [return: bb15, unwind: bb12]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
121129
}
122130

123-
bb16 (cleanup): {
124-
drop(_1) -> bb10; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
131+
bb18 (cleanup): {
132+
drop(_1) -> bb12; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
125133
}
126134

127-
bb17: {
135+
bb19: {
128136
_10 = discriminant(_1); // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
129-
switchInt(move _10) -> [0_isize: bb13, otherwise: bb15]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
137+
switchInt(move _10) -> [0_isize: bb15, otherwise: bb17]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
130138
}
131139

132-
bb18: {
133-
switchInt(_7) -> [false: bb13, otherwise: bb17]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
140+
bb20: {
141+
switchInt(_7) -> [false: bb15, otherwise: bb19]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
134142
}
135143

136-
bb19 (cleanup): {
144+
bb21 (cleanup): {
137145
_11 = discriminant(_1); // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
138-
switchInt(move _11) -> [0_isize: bb14, otherwise: bb16]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
146+
switchInt(move _11) -> [0_isize: bb16, otherwise: bb18]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
139147
}
140148

141-
bb20 (cleanup): {
142-
switchInt(_7) -> [false: bb10, otherwise: bb19]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
149+
bb22 (cleanup): {
150+
switchInt(_7) -> [false: bb12, otherwise: bb21]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2
143151
}
144152
}

‎src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn test() -> Option<Box<u32>> {
3030
StorageLive(_3); // scope 0 at $DIR/issue-62289.rs:9:15: 9:20
3131
StorageLive(_4); // scope 0 at $DIR/issue-62289.rs:9:15: 9:19
3232
_4 = Option::<u32>::None; // scope 0 at $DIR/issue-62289.rs:9:15: 9:19
33-
_3 = <Option<u32> as Try>::into_result(move _4) -> [return: bb1, unwind: bb9]; // scope 0 at $DIR/issue-62289.rs:9:15: 9:20
33+
_3 = <Option<u32> as Try>::into_result(move _4) -> [return: bb1, unwind: bb12]; // scope 0 at $DIR/issue-62289.rs:9:15: 9:20
3434
// mir::Constant
3535
// + span: $DIR/issue-62289.rs:9:15: 9:20
3636
// + literal: Const { ty: fn(std::option::Option<u32>) -> std::result::Result<<std::option::Option<u32> as std::ops::Try>::Ok, <std::option::Option<u32> as std::ops::Try>::Error> {<std::option::Option<u32> as std::ops::Try>::into_result}, val: Value(Scalar(<ZST>)) }
@@ -48,11 +48,7 @@ fn test() -> Option<Box<u32>> {
4848
(*_2) = _10; // scope 4 at $DIR/issue-62289.rs:9:15: 9:20
4949
StorageDead(_10); // scope 0 at $DIR/issue-62289.rs:9:19: 9:20
5050
_1 = move _2; // scope 0 at $DIR/issue-62289.rs:9:10: 9:21
51-
StorageDead(_2); // scope 0 at $DIR/issue-62289.rs:9:20: 9:21
52-
_0 = Option::<Box<u32>>::Some(move _1); // scope 0 at $DIR/issue-62289.rs:9:5: 9:22
53-
StorageDead(_1); // scope 0 at $DIR/issue-62289.rs:9:21: 9:22
54-
StorageDead(_3); // scope 0 at $DIR/issue-62289.rs:10:1: 10:2
55-
goto -> bb8; // scope 0 at $DIR/issue-62289.rs:10:2: 10:2
51+
drop(_2) -> [return: bb7, unwind: bb11]; // scope 0 at $DIR/issue-62289.rs:9:20: 9:21
5652
}
5753

5854
bb3: {
@@ -65,15 +61,15 @@ fn test() -> Option<Box<u32>> {
6561
StorageLive(_8); // scope 2 at $DIR/issue-62289.rs:9:19: 9:20
6662
StorageLive(_9); // scope 2 at $DIR/issue-62289.rs:9:19: 9:20
6763
_9 = _6; // scope 2 at $DIR/issue-62289.rs:9:19: 9:20
68-
_8 = <NoneError as From<NoneError>>::from(move _9) -> [return: bb5, unwind: bb9]; // scope 2 at $DIR/issue-62289.rs:9:19: 9:20
64+
_8 = <NoneError as From<NoneError>>::from(move _9) -> [return: bb5, unwind: bb12]; // scope 2 at $DIR/issue-62289.rs:9:19: 9:20
6965
// mir::Constant
7066
// + span: $DIR/issue-62289.rs:9:19: 9:20
7167
// + literal: Const { ty: fn(std::option::NoneError) -> std::option::NoneError {<std::option::NoneError as std::convert::From<std::option::NoneError>>::from}, val: Value(Scalar(<ZST>)) }
7268
}
7369

7470
bb5: {
7571
StorageDead(_9); // scope 2 at $DIR/issue-62289.rs:9:19: 9:20
76-
_0 = <Option<Box<u32>> as Try>::from_error(move _8) -> [return: bb6, unwind: bb9]; // scope 2 at $DIR/issue-62289.rs:9:15: 9:20
72+
_0 = <Option<Box<u32>> as Try>::from_error(move _8) -> [return: bb6, unwind: bb12]; // scope 2 at $DIR/issue-62289.rs:9:15: 9:20
7773
// mir::Constant
7874
// + span: $DIR/issue-62289.rs:9:15: 9:20
7975
// + literal: Const { ty: fn(<std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::Error) -> std::option::Option<std::boxed::Box<u32>> {<std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::from_error}, val: Value(Scalar(<ZST>)) }
@@ -82,25 +78,41 @@ fn test() -> Option<Box<u32>> {
8278
bb6: {
8379
StorageDead(_8); // scope 2 at $DIR/issue-62289.rs:9:19: 9:20
8480
StorageDead(_6); // scope 0 at $DIR/issue-62289.rs:9:19: 9:20
85-
drop(_2) -> bb7; // scope 0 at $DIR/issue-62289.rs:9:20: 9:21
81+
drop(_2) -> bb9; // scope 0 at $DIR/issue-62289.rs:9:20: 9:21
8682
}
8783

8884
bb7: {
85+
StorageDead(_2); // scope 0 at $DIR/issue-62289.rs:9:20: 9:21
86+
_0 = Option::<Box<u32>>::Some(move _1); // scope 0 at $DIR/issue-62289.rs:9:5: 9:22
87+
drop(_1) -> bb8; // scope 0 at $DIR/issue-62289.rs:9:21: 9:22
88+
}
89+
90+
bb8: {
91+
StorageDead(_1); // scope 0 at $DIR/issue-62289.rs:9:21: 9:22
92+
StorageDead(_3); // scope 0 at $DIR/issue-62289.rs:10:1: 10:2
93+
goto -> bb10; // scope 0 at $DIR/issue-62289.rs:10:2: 10:2
94+
}
95+
96+
bb9: {
8997
StorageDead(_2); // scope 0 at $DIR/issue-62289.rs:9:20: 9:21
9098
StorageDead(_1); // scope 0 at $DIR/issue-62289.rs:9:21: 9:22
9199
StorageDead(_3); // scope 0 at $DIR/issue-62289.rs:10:1: 10:2
92-
goto -> bb8; // scope 0 at $DIR/issue-62289.rs:10:2: 10:2
100+
goto -> bb10; // scope 0 at $DIR/issue-62289.rs:10:2: 10:2
93101
}
94102

95-
bb8: {
103+
bb10: {
96104
return; // scope 0 at $DIR/issue-62289.rs:10:2: 10:2
97105
}
98106

99-
bb9 (cleanup): {
100-
drop(_2) -> bb10; // scope 0 at $DIR/issue-62289.rs:9:20: 9:21
107+
bb11 (cleanup): {
108+
drop(_1) -> bb13; // scope 0 at $DIR/issue-62289.rs:9:21: 9:22
109+
}
110+
111+
bb12 (cleanup): {
112+
drop(_2) -> bb13; // scope 0 at $DIR/issue-62289.rs:9:20: 9:21
101113
}
102114

103-
bb10 (cleanup): {
115+
bb13 (cleanup): {
104116
resume; // scope 0 at $DIR/issue-62289.rs:8:1: 10:2
105117
}
106118
}

‎src/test/mir-opt/uniform_array_move_out.move_out_by_subslice.mir_map.0.mir

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,62 @@ fn move_out_by_subslice() -> () {
2222
_3 = Box(i32); // scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19
2323
(*_3) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19
2424
_2 = move _3; // scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19
25+
drop(_3) -> [return: bb1, unwind: bb9]; // scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19
26+
}
27+
28+
bb1: {
2529
StorageDead(_3); // scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19
2630
StorageLive(_4); // scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26
2731
StorageLive(_5); // scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26
2832
_5 = Box(i32); // scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26
2933
(*_5) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26
3034
_4 = move _5; // scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26
35+
drop(_5) -> [return: bb2, unwind: bb8]; // scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26
36+
}
37+
38+
bb2: {
3139
StorageDead(_5); // scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26
3240
_1 = [move _2, move _4]; // scope 0 at $DIR/uniform_array_move_out.rs:11:13: 11:27
41+
drop(_4) -> [return: bb3, unwind: bb9]; // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27
42+
}
43+
44+
bb3: {
3345
StorageDead(_4); // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27
46+
drop(_2) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27
47+
}
48+
49+
bb4: {
3450
StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27
3551
FakeRead(ForLet, _1); // scope 0 at $DIR/uniform_array_move_out.rs:11:9: 11:10
3652
StorageLive(_6); // scope 1 at $DIR/uniform_array_move_out.rs:12:10: 12:17
3753
_6 = move _1[0..2]; // scope 1 at $DIR/uniform_array_move_out.rs:12:10: 12:17
3854
_0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:10:27: 13:2
39-
drop(_6) -> [return: bb1, unwind: bb3]; // scope 1 at $DIR/uniform_array_move_out.rs:13:1: 13:2
55+
drop(_6) -> [return: bb5, unwind: bb7]; // scope 1 at $DIR/uniform_array_move_out.rs:13:1: 13:2
4056
}
4157

42-
bb1: {
58+
bb5: {
4359
StorageDead(_6); // scope 1 at $DIR/uniform_array_move_out.rs:13:1: 13:2
44-
drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2
60+
drop(_1) -> [return: bb6, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2
4561
}
4662

47-
bb2: {
63+
bb6: {
4864
StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2
4965
return; // scope 0 at $DIR/uniform_array_move_out.rs:13:2: 13:2
5066
}
5167

52-
bb3 (cleanup): {
53-
drop(_1) -> bb4; // scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2
68+
bb7 (cleanup): {
69+
drop(_1) -> bb10; // scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2
70+
}
71+
72+
bb8 (cleanup): {
73+
drop(_4) -> bb9; // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27
74+
}
75+
76+
bb9 (cleanup): {
77+
drop(_2) -> bb10; // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27
5478
}
5579

56-
bb4 (cleanup): {
80+
bb10 (cleanup): {
5781
resume; // scope 0 at $DIR/uniform_array_move_out.rs:10:1: 13:2
5882
}
5983
}

‎src/test/mir-opt/uniform_array_move_out.move_out_from_end.mir_map.0.mir

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,62 @@ fn move_out_from_end() -> () {
2222
_3 = Box(i32); // scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19
2323
(*_3) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19
2424
_2 = move _3; // scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19
25+
drop(_3) -> [return: bb1, unwind: bb9]; // scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19
26+
}
27+
28+
bb1: {
2529
StorageDead(_3); // scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19
2630
StorageLive(_4); // scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26
2731
StorageLive(_5); // scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26
2832
_5 = Box(i32); // scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26
2933
(*_5) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26
3034
_4 = move _5; // scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26
35+
drop(_5) -> [return: bb2, unwind: bb8]; // scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26
36+
}
37+
38+
bb2: {
3139
StorageDead(_5); // scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26
3240
_1 = [move _2, move _4]; // scope 0 at $DIR/uniform_array_move_out.rs:5:13: 5:27
41+
drop(_4) -> [return: bb3, unwind: bb9]; // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27
42+
}
43+
44+
bb3: {
3345
StorageDead(_4); // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27
46+
drop(_2) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27
47+
}
48+
49+
bb4: {
3450
StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27
3551
FakeRead(ForLet, _1); // scope 0 at $DIR/uniform_array_move_out.rs:5:9: 5:10
3652
StorageLive(_6); // scope 1 at $DIR/uniform_array_move_out.rs:6:14: 6:16
3753
_6 = move _1[1 of 2]; // scope 1 at $DIR/uniform_array_move_out.rs:6:14: 6:16
3854
_0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:4:24: 7:2
39-
drop(_6) -> [return: bb1, unwind: bb3]; // scope 1 at $DIR/uniform_array_move_out.rs:7:1: 7:2
55+
drop(_6) -> [return: bb5, unwind: bb7]; // scope 1 at $DIR/uniform_array_move_out.rs:7:1: 7:2
4056
}
4157

42-
bb1: {
58+
bb5: {
4359
StorageDead(_6); // scope 1 at $DIR/uniform_array_move_out.rs:7:1: 7:2
44-
drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2
60+
drop(_1) -> [return: bb6, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2
4561
}
4662

47-
bb2: {
63+
bb6: {
4864
StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2
4965
return; // scope 0 at $DIR/uniform_array_move_out.rs:7:2: 7:2
5066
}
5167

52-
bb3 (cleanup): {
53-
drop(_1) -> bb4; // scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2
68+
bb7 (cleanup): {
69+
drop(_1) -> bb10; // scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2
70+
}
71+
72+
bb8 (cleanup): {
73+
drop(_4) -> bb9; // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27
74+
}
75+
76+
bb9 (cleanup): {
77+
drop(_2) -> bb10; // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27
5478
}
5579

56-
bb4 (cleanup): {
80+
bb10 (cleanup): {
5781
resume; // scope 0 at $DIR/uniform_array_move_out.rs:4:1: 7:2
5882
}
5983
}

0 commit comments

Comments
 (0)
Please sign in to comment.