]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_hir/src/hir.rs
Rollup merge of #82510 - jyn514:fix-typo, r=Dylan-DPC
[rust.git] / compiler / rustc_hir / src / hir.rs
index 2fef7c2cc087d4097e1d388ace6a2db18dec53f0..f4402843afcbe5bd678bfc1e4ffb8c18b22c3024 100644 (file)
@@ -1577,6 +1577,14 @@ pub fn peel_drop_temps(&self) -> &Self {
         expr
     }
 
+    pub fn peel_blocks(&self) -> &Self {
+        let mut expr = self;
+        while let ExprKind::Block(Block { expr: Some(inner), .. }, _) = &expr.kind {
+            expr = inner;
+        }
+        expr
+    }
+
     pub fn can_have_side_effects(&self) -> bool {
         match self.peel_drop_temps().kind {
             ExprKind::Path(_) | ExprKind::Lit(_) => false,