Store blocks in Thir.
Like expressions, statements, and match arms. This shrinks `thir::Stmt` and is a precursor to further shrinking `thir::Expr`.
This commit is contained in:
@@ -75,6 +75,7 @@ macro_rules! thir_with_elements {
|
||||
|
||||
thir_with_elements! {
|
||||
arms: ArmId => Arm<'tcx> => "a{}",
|
||||
blocks: BlockId => Block => "b{}",
|
||||
exprs: ExprId => Expr<'tcx> => "e{}",
|
||||
stmts: StmtId => Stmt<'tcx> => "s{}",
|
||||
}
|
||||
@@ -168,7 +169,7 @@ pub enum StmtKind<'tcx> {
|
||||
initializer: Option<ExprId>,
|
||||
|
||||
/// `let pat: ty = <INIT> else { <ELSE> }
|
||||
else_block: Option<Block>,
|
||||
else_block: Option<BlockId>,
|
||||
|
||||
/// The lint level for this `let` statement.
|
||||
lint_level: LintLevel,
|
||||
@@ -292,7 +293,7 @@ pub enum ExprKind<'tcx> {
|
||||
},
|
||||
/// A block.
|
||||
Block {
|
||||
body: Block,
|
||||
block: BlockId,
|
||||
},
|
||||
/// An assignment: `lhs = rhs`.
|
||||
Assign {
|
||||
@@ -802,5 +803,5 @@ mod size_asserts {
|
||||
static_assert_size!(Block, 56);
|
||||
static_assert_size!(Expr<'_>, 88);
|
||||
static_assert_size!(Pat<'_>, 24);
|
||||
static_assert_size!(Stmt<'_>, 120);
|
||||
static_assert_size!(Stmt<'_>, 72);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ pub fn walk_expr<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, expr: &Exp
|
||||
visitor.visit_arm(&visitor.thir()[arm]);
|
||||
}
|
||||
}
|
||||
Block { ref body } => visitor.visit_block(body),
|
||||
Block { block } => visitor.visit_block(&visitor.thir()[block]),
|
||||
Assign { lhs, rhs } | AssignOp { lhs, rhs, op: _ } => {
|
||||
visitor.visit_expr(&visitor.thir()[lhs]);
|
||||
visitor.visit_expr(&visitor.thir()[rhs]);
|
||||
@@ -174,7 +174,7 @@ pub fn walk_stmt<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, stmt: &Stm
|
||||
}
|
||||
visitor.visit_pat(pattern);
|
||||
if let Some(block) = else_block {
|
||||
visitor.visit_block(block)
|
||||
visitor.visit_block(&visitor.thir()[*block])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user