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