Skip to content

Commit 1cf4eb2

Browse files
committed
Stop using unpack! for BlockAnd<()>
1 parent 4fe8dd0 commit 1cf4eb2

File tree

8 files changed

+26
-29
lines changed

8 files changed

+26
-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+
.into_block();
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+
.into_block();
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+
.into_block();
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).into_block();
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).into_block();
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+
.into_block();
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).into_block();
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

+3-3
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ 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.expr_into_dest(destination, else_blk, else_expr).into_block();
111111
} else {
112112
// There is no `else` arm, so we know both arms have type `()`.
113113
// Generate the implicit `else {}` by assigning unit.
@@ -506,7 +506,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
506506

507507
// These cases don't actually need a destination
508508
ExprKind::Assign { .. } | ExprKind::AssignOp { .. } => {
509-
unpack!(block = this.stmt_expr(block, expr_id, None));
509+
block = this.stmt_expr(block, expr_id, None).into_block();
510510
this.cfg.push_assign_unit(block, source_info, destination, this.tcx);
511511
block.unit()
512512
}
@@ -515,7 +515,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
515515
| ExprKind::Break { .. }
516516
| ExprKind::Return { .. }
517517
| ExprKind::Become { .. } => {
518-
unpack!(block = this.stmt_expr(block, expr_id, None));
518+
block = this.stmt_expr(block, expr_id, None).into_block();
519519
// No assign, as these have type `!`.
520520
block.unit()
521521
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ 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 =
46+
this.build_drop_and_replace(block, lhs_expr.span, lhs, rhs).into_block();
4647
} else {
4748
let rhs = unpack!(block = this.as_local_rvalue(block, rhs));
4849
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
@@ -625,7 +625,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
625625
OutsideGuard,
626626
ScheduleDrops::Yes,
627627
);
628-
unpack!(block = self.expr_into_dest(place, block, initializer_id));
628+
block = self.expr_into_dest(place, block, initializer_id).into_block();
629629

630630
// Inject a fake read, see comments on `FakeReadCause::ForLet`.
631631
let source_info = self.source_info(irrefutable_pat.span);
@@ -664,7 +664,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
664664
OutsideGuard,
665665
ScheduleDrops::Yes,
666666
);
667-
unpack!(block = self.expr_into_dest(place, block, initializer_id));
667+
block = self.expr_into_dest(place, block, initializer_id).into_block();
668668

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

compiler/rustc_mir_build/src/build/mod.rs

+2-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).into_block();
588588

589589
let source_info = builder.source_info(span);
590590
builder.cfg.terminate(block, source_info, TerminatorKind::Return);
@@ -966,7 +966,7 @@ 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.place_into_pattern(block, pat, place_builder, false).into_block();
970970
}
971971
}
972972
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).into_block();
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).into_block();
663663
self.block_context.pop();
664664
}
665665
(Some(destination), None) => {

0 commit comments

Comments
 (0)