From 2df805fc7a98b5bea7022901ea7f837a13a51186 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 24 Aug 2022 12:02:17 +1000 Subject: Store blocks in `Thir`. Like expressions, statements, and match arms. This shrinks `thir::Stmt` and is a precursor to further shrinking `thir::Expr`. --- compiler/rustc_ty_utils/src/consts.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'compiler/rustc_ty_utils') diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs index 7c2f4db94ff..e8ce8e6f23e 100644 --- a/compiler/rustc_ty_utils/src/consts.rs +++ b/compiler/rustc_ty_utils/src/consts.rs @@ -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", -- cgit 1.4.1-3-g733a5