Skip to content

Commit 5066e6c

Browse files
committed
Stop using unpack! for BlockAnd<()>
1 parent d9b0e97 commit 5066e6c

File tree

8 files changed

+31
-29
lines changed

8 files changed

+31
-29
lines changed

compiler/rustc_mir_build/src/build/block.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
7171
StmtKind::Expr { scope, expr } => {
7272
this.block_context.push(BlockFrame::Statement { ignores_expr_result: true });
7373
let si = (*scope, source_info);
74-
unpack!(
75-
block = this.in_scope(si, LintLevel::Inherited, |this| {
74+
block = this
75+
.in_scope(si, LintLevel::Inherited, |this| {
7676
this.stmt_expr(block, *expr, Some(*scope))
7777
})
78-
);
78+
.unpack_block_and_unit();
7979
}
8080
StmtKind::Let {
8181
remainder_scope,
@@ -166,14 +166,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
166166
let dummy_place = this.temp(this.tcx.types.never, else_block_span);
167167
let failure_entry = this.cfg.start_new_block();
168168
let failure_block;
169-
unpack!(
170-
failure_block = this.ast_block(
169+
failure_block = this
170+
.ast_block(
171171
dummy_place,
172172
failure_entry,
173173
*else_block,
174174
this.source_info(else_block_span),
175175
)
176-
);
176+
.unpack_block_and_unit();
177177
this.cfg.terminate(
178178
failure_block,
179179
this.source_info(else_block_span),
@@ -267,8 +267,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
267267
let initializer_span = this.thir[init].span;
268268
let scope = (*init_scope, source_info);
269269

270-
unpack!(
271-
block = this.in_scope(scope, *lint_level, |this| {
270+
block = this
271+
.in_scope(scope, *lint_level, |this| {
272272
this.declare_bindings(
273273
visibility_scope,
274274
remainder_span,
@@ -279,7 +279,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
279279
this.expr_into_pattern(block, &pattern, init)
280280
// irrefutable pattern
281281
})
282-
)
282+
.unpack_block_and_unit();
283283
} else {
284284
let scope = (*init_scope, source_info);
285285
let _: BlockAnd<()> = this.in_scope(scope, *lint_level, |this| {
@@ -333,7 +333,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
333333
this.block_context
334334
.push(BlockFrame::TailExpr { tail_result_is_ignored, span: expr.span });
335335

336-
unpack!(block = this.expr_into_dest(destination, block, expr_id));
336+
block = this.expr_into_dest(destination, block, expr_id).unpack_block_and_unit();
337337
let popped = this.block_context.pop();
338338

339339
assert!(popped.is_some_and(|bf| bf.is_tail_expr()));
@@ -355,7 +355,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
355355
// Finally, we pop all the let scopes before exiting out from the scope of block
356356
// itself.
357357
for scope in let_scope_stack.into_iter().rev() {
358-
unpack!(block = this.pop_scope((*scope, source_info), block));
358+
block = this.pop_scope((*scope, source_info), block).unpack_block_and_unit();
359359
}
360360
// Restore the original source scope.
361361
this.source_scope = outer_source_scope;

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

+3-7
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
185185
this.cfg.push_assign(block, source_info, Place::from(result), box_);
186186

187187
// initialize the box contents:
188-
unpack!(
189-
block = this.expr_into_dest(
190-
this.tcx.mk_place_deref(Place::from(result)),
191-
block,
192-
value,
193-
)
194-
);
188+
block = this
189+
.expr_into_dest(this.tcx.mk_place_deref(Place::from(result)), block, value)
190+
.unpack_block_and_unit();
195191
block.and(Rvalue::Use(Operand::Move(Place::from(result))))
196192
}
197193
ExprKind::Cast { source } => {

compiler/rustc_mir_build/src/build/expr/as_temp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
112112
}
113113
}
114114

115-
unpack!(block = this.expr_into_dest(temp_place, block, expr_id));
115+
block = this.expr_into_dest(temp_place, block, expr_id).unpack_block_and_unit();
116116

117117
if let Some(temp_lifetime) = temp_lifetime {
118118
this.schedule_drop(expr_span, temp_lifetime, temp, DropKind::Value);

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
107107

108108
// If there is an `else` arm, lower it into `else_blk`.
109109
if let Some(else_expr) = else_opt {
110-
unpack!(else_blk = this.expr_into_dest(destination, else_blk, else_expr));
110+
else_blk = this
111+
.expr_into_dest(destination, else_blk, else_expr)
112+
.unpack_block_and_unit();
111113
} else {
112114
// There is no `else` arm, so we know both arms have type `()`.
113115
// Generate the implicit `else {}` by assigning unit.
@@ -508,7 +510,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
508510

509511
// These cases don't actually need a destination
510512
ExprKind::Assign { .. } | ExprKind::AssignOp { .. } => {
511-
unpack!(block = this.stmt_expr(block, expr_id, None));
513+
block = this.stmt_expr(block, expr_id, None).unpack_block_and_unit();
512514
this.cfg.push_assign_unit(block, source_info, destination, this.tcx);
513515
block.unit()
514516
}
@@ -517,7 +519,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
517519
| ExprKind::Break { .. }
518520
| ExprKind::Return { .. }
519521
| ExprKind::Become { .. } => {
520-
unpack!(block = this.stmt_expr(block, expr_id, None));
522+
block = this.stmt_expr(block, expr_id, None).unpack_block_and_unit();
521523
// No assign, as these have type `!`.
522524
block.unit()
523525
}

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
4242
if lhs_expr.ty.needs_drop(this.tcx, this.param_env) {
4343
let rhs = unpack!(block = this.as_local_rvalue(block, rhs));
4444
let lhs = unpack!(block = this.as_place(block, lhs));
45-
unpack!(block = this.build_drop_and_replace(block, lhs_expr.span, lhs, rhs));
45+
block = this
46+
.build_drop_and_replace(block, lhs_expr.span, lhs, rhs)
47+
.unpack_block_and_unit();
4648
} else {
4749
let rhs = unpack!(block = this.as_local_rvalue(block, rhs));
4850
let lhs = unpack!(block = this.as_place(block, lhs));

compiler/rustc_mir_build/src/build/matches/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
626626
OutsideGuard,
627627
ScheduleDrops::Yes,
628628
);
629-
unpack!(block = self.expr_into_dest(place, block, initializer_id));
629+
block = self.expr_into_dest(place, block, initializer_id).unpack_block_and_unit();
630630

631631
// Inject a fake read, see comments on `FakeReadCause::ForLet`.
632632
let source_info = self.source_info(irrefutable_pat.span);
@@ -665,7 +665,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
665665
OutsideGuard,
666666
ScheduleDrops::Yes,
667667
);
668-
unpack!(block = self.expr_into_dest(place, block, initializer_id));
668+
block = self.expr_into_dest(place, block, initializer_id).unpack_block_and_unit();
669669

670670
// Inject a fake read, see comments on `FakeReadCause::ForLet`.
671671
let pattern_source_info = self.source_info(irrefutable_pat.span);

compiler/rustc_mir_build/src/build/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ fn construct_const<'a, 'tcx>(
584584
Builder::new(thir, infcx, def, hir_id, span, 0, const_ty, const_ty_span, None);
585585

586586
let mut block = START_BLOCK;
587-
unpack!(block = builder.expr_into_dest(Place::return_place(), block, expr));
587+
block = builder.expr_into_dest(Place::return_place(), block, expr).unpack_block_and_unit();
588588

589589
let source_info = builder.source_info(span);
590590
builder.cfg.terminate(block, source_info, TerminatorKind::Return);
@@ -966,7 +966,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
966966
Some((Some(&place), span)),
967967
);
968968
let place_builder = PlaceBuilder::from(local);
969-
unpack!(block = self.place_into_pattern(block, pat, place_builder, false));
969+
block = self
970+
.place_into_pattern(block, pat, place_builder, false)
971+
.unpack_block_and_unit();
970972
}
971973
}
972974
self.source_scope = original_source_scope;

compiler/rustc_mir_build/src/build/scope.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
587587
self.push_scope(region_scope);
588588
let mut block;
589589
let rv = unpack!(block = f(self));
590-
unpack!(block = self.pop_scope(region_scope, block));
590+
block = self.pop_scope(region_scope, block).unpack_block_and_unit();
591591
self.source_scope = source_scope;
592592
debug!(?block);
593593
block.and(rv)
@@ -659,7 +659,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
659659
(Some(destination), Some(value)) => {
660660
debug!("stmt_expr Break val block_context.push(SubExpr)");
661661
self.block_context.push(BlockFrame::SubExpr);
662-
unpack!(block = self.expr_into_dest(destination, block, value));
662+
block = self.expr_into_dest(destination, block, value).unpack_block_and_unit();
663663
self.block_context.pop();
664664
}
665665
(Some(destination), None) => {

0 commit comments

Comments
 (0)