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:
parent
e7c25c3a97
commit
2df805fc7a
11 changed files with 66 additions and 47 deletions
|
@ -311,8 +311,15 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
|
|||
// bar::<{ N + 1 }>();
|
||||
// }
|
||||
// ```
|
||||
ExprKind::Block { body: thir::Block { stmts: box [], expr: Some(e), .. } } => {
|
||||
self.recurse_build(*e)?
|
||||
ExprKind::Block { block } => {
|
||||
if let thir::Block { stmts: box [], expr: Some(e), .. } = &self.body.blocks[*block] {
|
||||
self.recurse_build(*e)?
|
||||
} else {
|
||||
self.maybe_supported_error(
|
||||
node.span,
|
||||
"blocks are not supported in generic constant",
|
||||
)?
|
||||
}
|
||||
}
|
||||
// `ExprKind::Use` happens when a `hir::ExprKind::Cast` is a
|
||||
// "coercion cast" i.e. using a coercion or is a no-op.
|
||||
|
@ -349,10 +356,6 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
|
|||
node.span,
|
||||
"array construction is not supported in generic constants",
|
||||
)?,
|
||||
ExprKind::Block { .. } => self.maybe_supported_error(
|
||||
node.span,
|
||||
"blocks are not supported in generic constant",
|
||||
)?,
|
||||
ExprKind::NeverToAny { .. } => self.maybe_supported_error(
|
||||
node.span,
|
||||
"converting nevers to any is not supported in generic constant",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue