mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Stop using unpack!
for BlockAnd<()>
This commit is contained in:
parent
4fe8dd05ed
commit
1cf4eb2ad2
@ -71,11 +71,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
StmtKind::Expr { scope, expr } => {
|
||||
this.block_context.push(BlockFrame::Statement { ignores_expr_result: true });
|
||||
let si = (*scope, source_info);
|
||||
unpack!(
|
||||
block = this.in_scope(si, LintLevel::Inherited, |this| {
|
||||
block = this
|
||||
.in_scope(si, LintLevel::Inherited, |this| {
|
||||
this.stmt_expr(block, *expr, Some(*scope))
|
||||
})
|
||||
);
|
||||
.into_block();
|
||||
}
|
||||
StmtKind::Let {
|
||||
remainder_scope,
|
||||
@ -166,14 +166,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
let dummy_place = this.temp(this.tcx.types.never, else_block_span);
|
||||
let failure_entry = this.cfg.start_new_block();
|
||||
let failure_block;
|
||||
unpack!(
|
||||
failure_block = this.ast_block(
|
||||
failure_block = this
|
||||
.ast_block(
|
||||
dummy_place,
|
||||
failure_entry,
|
||||
*else_block,
|
||||
this.source_info(else_block_span),
|
||||
)
|
||||
);
|
||||
.into_block();
|
||||
this.cfg.terminate(
|
||||
failure_block,
|
||||
this.source_info(else_block_span),
|
||||
@ -267,8 +267,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
let initializer_span = this.thir[init].span;
|
||||
let scope = (*init_scope, source_info);
|
||||
|
||||
unpack!(
|
||||
block = this.in_scope(scope, *lint_level, |this| {
|
||||
block = this
|
||||
.in_scope(scope, *lint_level, |this| {
|
||||
this.declare_bindings(
|
||||
visibility_scope,
|
||||
remainder_span,
|
||||
@ -279,7 +279,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
this.expr_into_pattern(block, &pattern, init)
|
||||
// irrefutable pattern
|
||||
})
|
||||
)
|
||||
.into_block();
|
||||
} else {
|
||||
let scope = (*init_scope, source_info);
|
||||
let _: BlockAnd<()> = this.in_scope(scope, *lint_level, |this| {
|
||||
@ -333,7 +333,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
this.block_context
|
||||
.push(BlockFrame::TailExpr { tail_result_is_ignored, span: expr.span });
|
||||
|
||||
unpack!(block = this.expr_into_dest(destination, block, expr_id));
|
||||
block = this.expr_into_dest(destination, block, expr_id).into_block();
|
||||
let popped = this.block_context.pop();
|
||||
|
||||
assert!(popped.is_some_and(|bf| bf.is_tail_expr()));
|
||||
@ -355,7 +355,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
// Finally, we pop all the let scopes before exiting out from the scope of block
|
||||
// itself.
|
||||
for scope in let_scope_stack.into_iter().rev() {
|
||||
unpack!(block = this.pop_scope((*scope, source_info), block));
|
||||
block = this.pop_scope((*scope, source_info), block).into_block();
|
||||
}
|
||||
// Restore the original source scope.
|
||||
this.source_scope = outer_source_scope;
|
||||
|
@ -185,13 +185,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
this.cfg.push_assign(block, source_info, Place::from(result), box_);
|
||||
|
||||
// initialize the box contents:
|
||||
unpack!(
|
||||
block = this.expr_into_dest(
|
||||
this.tcx.mk_place_deref(Place::from(result)),
|
||||
block,
|
||||
value,
|
||||
)
|
||||
);
|
||||
block = this
|
||||
.expr_into_dest(this.tcx.mk_place_deref(Place::from(result)), block, value)
|
||||
.into_block();
|
||||
block.and(Rvalue::Use(Operand::Move(Place::from(result))))
|
||||
}
|
||||
ExprKind::Cast { source } => {
|
||||
|
@ -112,7 +112,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
unpack!(block = this.expr_into_dest(temp_place, block, expr_id));
|
||||
block = this.expr_into_dest(temp_place, block, expr_id).into_block();
|
||||
|
||||
if let Some(temp_lifetime) = temp_lifetime {
|
||||
this.schedule_drop(expr_span, temp_lifetime, temp, DropKind::Value);
|
||||
|
@ -107,7 +107,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
|
||||
// If there is an `else` arm, lower it into `else_blk`.
|
||||
if let Some(else_expr) = else_opt {
|
||||
unpack!(else_blk = this.expr_into_dest(destination, else_blk, else_expr));
|
||||
else_blk = this.expr_into_dest(destination, else_blk, else_expr).into_block();
|
||||
} else {
|
||||
// There is no `else` arm, so we know both arms have type `()`.
|
||||
// Generate the implicit `else {}` by assigning unit.
|
||||
@ -506,7 +506,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
|
||||
// These cases don't actually need a destination
|
||||
ExprKind::Assign { .. } | ExprKind::AssignOp { .. } => {
|
||||
unpack!(block = this.stmt_expr(block, expr_id, None));
|
||||
block = this.stmt_expr(block, expr_id, None).into_block();
|
||||
this.cfg.push_assign_unit(block, source_info, destination, this.tcx);
|
||||
block.unit()
|
||||
}
|
||||
@ -515,7 +515,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
| ExprKind::Break { .. }
|
||||
| ExprKind::Return { .. }
|
||||
| ExprKind::Become { .. } => {
|
||||
unpack!(block = this.stmt_expr(block, expr_id, None));
|
||||
block = this.stmt_expr(block, expr_id, None).into_block();
|
||||
// No assign, as these have type `!`.
|
||||
block.unit()
|
||||
}
|
||||
|
@ -42,7 +42,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
if lhs_expr.ty.needs_drop(this.tcx, this.param_env) {
|
||||
let rhs = unpack!(block = this.as_local_rvalue(block, rhs));
|
||||
let lhs = unpack!(block = this.as_place(block, lhs));
|
||||
unpack!(block = this.build_drop_and_replace(block, lhs_expr.span, lhs, rhs));
|
||||
block =
|
||||
this.build_drop_and_replace(block, lhs_expr.span, lhs, rhs).into_block();
|
||||
} else {
|
||||
let rhs = unpack!(block = this.as_local_rvalue(block, rhs));
|
||||
let lhs = unpack!(block = this.as_place(block, lhs));
|
||||
|
@ -625,7 +625,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
OutsideGuard,
|
||||
ScheduleDrops::Yes,
|
||||
);
|
||||
unpack!(block = self.expr_into_dest(place, block, initializer_id));
|
||||
block = self.expr_into_dest(place, block, initializer_id).into_block();
|
||||
|
||||
// Inject a fake read, see comments on `FakeReadCause::ForLet`.
|
||||
let source_info = self.source_info(irrefutable_pat.span);
|
||||
@ -664,7 +664,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
OutsideGuard,
|
||||
ScheduleDrops::Yes,
|
||||
);
|
||||
unpack!(block = self.expr_into_dest(place, block, initializer_id));
|
||||
block = self.expr_into_dest(place, block, initializer_id).into_block();
|
||||
|
||||
// Inject a fake read, see comments on `FakeReadCause::ForLet`.
|
||||
let pattern_source_info = self.source_info(irrefutable_pat.span);
|
||||
|
@ -584,7 +584,7 @@ fn construct_const<'a, 'tcx>(
|
||||
Builder::new(thir, infcx, def, hir_id, span, 0, const_ty, const_ty_span, None);
|
||||
|
||||
let mut block = START_BLOCK;
|
||||
unpack!(block = builder.expr_into_dest(Place::return_place(), block, expr));
|
||||
block = builder.expr_into_dest(Place::return_place(), block, expr).into_block();
|
||||
|
||||
let source_info = builder.source_info(span);
|
||||
builder.cfg.terminate(block, source_info, TerminatorKind::Return);
|
||||
@ -966,7 +966,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
Some((Some(&place), span)),
|
||||
);
|
||||
let place_builder = PlaceBuilder::from(local);
|
||||
unpack!(block = self.place_into_pattern(block, pat, place_builder, false));
|
||||
block = self.place_into_pattern(block, pat, place_builder, false).into_block();
|
||||
}
|
||||
}
|
||||
self.source_scope = original_source_scope;
|
||||
|
@ -587,7 +587,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
self.push_scope(region_scope);
|
||||
let mut block;
|
||||
let rv = unpack!(block = f(self));
|
||||
unpack!(block = self.pop_scope(region_scope, block));
|
||||
block = self.pop_scope(region_scope, block).into_block();
|
||||
self.source_scope = source_scope;
|
||||
debug!(?block);
|
||||
block.and(rv)
|
||||
@ -659,7 +659,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
(Some(destination), Some(value)) => {
|
||||
debug!("stmt_expr Break val block_context.push(SubExpr)");
|
||||
self.block_context.push(BlockFrame::SubExpr);
|
||||
unpack!(block = self.expr_into_dest(destination, block, value));
|
||||
block = self.expr_into_dest(destination, block, value).into_block();
|
||||
self.block_context.pop();
|
||||
}
|
||||
(Some(destination), None) => {
|
||||
|
Loading…
Reference in New Issue
Block a user