about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-08-26 10:00:27 +0000
committerbors <bors@rust-lang.org>2022-08-26 10:00:27 +0000
commit8a13871b69924b74cfa1d737f2894068b37ea7ea (patch)
tree005775f17a3b5454f4686d5a6fd87a9d3fbc414b /compiler/rustc_ty_utils
parent983f4daddf238d114c4adc4751c5528fc6695a5a (diff)
parent5a41eb81cabaa074072eb5f76a3ba771c7e68899 (diff)
downloadrust-8a13871b69924b74cfa1d737f2894068b37ea7ea.tar.gz
rust-8a13871b69924b74cfa1d737f2894068b37ea7ea.zip
Auto merge of #100944 - nnethercote:shrink-thir-Expr, r=cjgillot
Shrink `thir::Expr`

r? `@cjgillot`
Diffstat (limited to 'compiler/rustc_ty_utils')
-rw-r--r--compiler/rustc_ty_utils/src/consts.rs15
1 files changed, 9 insertions, 6 deletions
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",