Put a BlockTailInfo
in BlockFrame::TailExpr
.
Because it has the same fields, and avoids the need to deconstruct the latter to construct the former.
This commit is contained in:
parent
5d2d11fd5d
commit
c49e2df668
4 changed files with 10 additions and 21 deletions
|
@ -331,8 +331,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
let expr = &this.thir[expr_id];
|
||||
let tail_result_is_ignored =
|
||||
destination_ty.is_unit() || this.block_context.currently_ignores_tail_results();
|
||||
this.block_context
|
||||
.push(BlockFrame::TailExpr { tail_result_is_ignored, span: expr.span });
|
||||
this.block_context.push(BlockFrame::TailExpr {
|
||||
info: BlockTailInfo { tail_result_is_ignored, span: expr.span },
|
||||
});
|
||||
|
||||
block = this.expr_into_dest(destination, block, expr_id).into_block();
|
||||
let popped = this.block_context.pop();
|
||||
|
|
|
@ -164,8 +164,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
this.block_context.push(BlockFrame::TailExpr {
|
||||
tail_result_is_ignored: true,
|
||||
span: expr.span,
|
||||
info: BlockTailInfo { tail_result_is_ignored: true, span: expr.span },
|
||||
});
|
||||
Some(expr.span)
|
||||
} else {
|
||||
|
|
|
@ -112,16 +112,7 @@ enum BlockFrame {
|
|||
/// Evaluation is currently within the tail expression of a block.
|
||||
///
|
||||
/// Example: `{ STMT_1; STMT_2; EXPR }`
|
||||
TailExpr {
|
||||
/// If true, then the surrounding context of the block ignores
|
||||
/// the result of evaluating the block's tail expression.
|
||||
///
|
||||
/// Example: `let _ = { STMT_1; EXPR };`
|
||||
tail_result_is_ignored: bool,
|
||||
|
||||
/// `Span` of the tail expression.
|
||||
span: Span,
|
||||
},
|
||||
TailExpr { info: BlockTailInfo },
|
||||
|
||||
/// Generic mark meaning that the block occurred as a subexpression
|
||||
/// where the result might be used.
|
||||
|
@ -277,9 +268,7 @@ impl BlockContext {
|
|||
match bf {
|
||||
BlockFrame::SubExpr => continue,
|
||||
BlockFrame::Statement { .. } => break,
|
||||
&BlockFrame::TailExpr { tail_result_is_ignored, span } => {
|
||||
return Some(BlockTailInfo { tail_result_is_ignored, span });
|
||||
}
|
||||
&BlockFrame::TailExpr { info } => return Some(info),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -302,9 +291,9 @@ impl BlockContext {
|
|||
|
||||
// otherwise: use accumulated is_ignored state.
|
||||
Some(
|
||||
BlockFrame::TailExpr { tail_result_is_ignored: ignored, .. }
|
||||
| BlockFrame::Statement { ignores_expr_result: ignored },
|
||||
) => *ignored,
|
||||
BlockFrame::TailExpr { info: BlockTailInfo { tail_result_is_ignored: ign, .. } }
|
||||
| BlockFrame::Statement { ignores_expr_result: ign },
|
||||
) => *ign,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue