about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeSeulArtichaut <leseulartichaut@gmail.com>2021-03-07 00:21:14 +0100
committerLeSeulArtichaut <leseulartichaut@gmail.com>2021-03-09 20:15:03 +0100
commitd6c737adb50e194beca9cf0c0a87037738ae8a58 (patch)
tree1f9043c09d6a3554ad1d6d577108b0acb1c1091b
parent5f38c839ad306bf230adb5f27b98983f1d04722b (diff)
downloadrust-d6c737adb50e194beca9cf0c0a87037738ae8a58.tar.gz
rust-d6c737adb50e194beca9cf0c0a87037738ae8a58.zip
Take into account `ExprKind::Scope` when calculating span of temporary
-rw-r--r--compiler/rustc_mir_build/src/build/expr/stmt.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_mir_build/src/build/expr/stmt.rs b/compiler/rustc_mir_build/src/build/expr/stmt.rs
index a3fbd21642d..f01315fc5db 100644
--- a/compiler/rustc_mir_build/src/build/expr/stmt.rs
+++ b/compiler/rustc_mir_build/src/build/expr/stmt.rs
@@ -141,12 +141,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                     if let ExprKind::Block { body } = &expr.kind {
                         if let Some(tail_expr) = &body.expr {
                             let mut expr = &*tail_expr;
-                            while let ExprKind::Block { body: subblock } = &expr.kind {
-                                if let Some(subtail_expr) = &subblock.expr {
-                                    expr = subtail_expr
-                                } else {
-                                    break;
-                                }
+                            while let ExprKind::Block {
+                                body: Block { expr: Some(nested_expr), .. },
+                            }
+                            | ExprKind::Scope { value: nested_expr, .. } = &expr.kind
+                            {
+                                expr = nested_expr;
                             }
                             this.block_context.push(BlockFrame::TailExpr {
                                 tail_result_is_ignored: true,