]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_mir_build/src/build/expr/stmt.rs
Auto merge of #94477 - matthiaskrgr:rollup-8h29qek, r=matthiaskrgr
[rust.git] / compiler / rustc_mir_build / src / build / expr / stmt.rs
index 7419c5b2f7588e56a556db5ad4fcc3efbd386517..46c616ff362414a2668c48c22cf3eaf3522f53fa 100644 (file)
@@ -116,22 +116,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                 // it is usually better to focus on `the_value` rather
                 // than the entirety of block(s) surrounding it.
                 let adjusted_span = (|| {
-                    if let ExprKind::Block { body } = &expr.kind {
-                        if let Some(tail_expr) = body.expr {
-                            let mut expr = &this.thir[tail_expr];
-                            while let ExprKind::Block {
-                                body: Block { expr: Some(nested_expr), .. },
-                            }
-                            | ExprKind::Scope { value: nested_expr, .. } = expr.kind
-                            {
-                                expr = &this.thir[nested_expr];
-                            }
-                            this.block_context.push(BlockFrame::TailExpr {
-                                tail_result_is_ignored: true,
-                                span: expr.span,
-                            });
-                            return Some(expr.span);
+                    if let ExprKind::Block { body } = &expr.kind && let Some(tail_ex) = body.expr {
+                        let mut expr = &this.thir[tail_ex];
+                        while let ExprKind::Block {
+                            body: Block { expr: Some(nested_expr), .. },
                         }
+                        | ExprKind::Scope { value: nested_expr, .. } = expr.kind
+                        {
+                            expr = &this.thir[nested_expr];
+                        }
+                        this.block_context.push(BlockFrame::TailExpr {
+                            tail_result_is_ignored: true,
+                            span: expr.span,
+                        });
+                        return Some(expr.span);
                     }
                     None
                 })();