]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/fold.rs
Auto merge of #53815 - F001:if-let-guard, r=petrochenkov
[rust.git] / src / libsyntax / fold.rs
index 660056e15e06b61f669c6d3fc16a4c1d5c089166..dff408d233977b559c99dce845735fba927c8956 100644 (file)
@@ -118,6 +118,10 @@ fn fold_arm(&mut self, a: Arm) -> Arm {
         noop_fold_arm(a, self)
     }
 
+    fn fold_guard(&mut self, g: Guard) -> Guard {
+        noop_fold_guard(g, self)
+    }
+
     fn fold_pat(&mut self, p: P<Pat>) -> P<Pat> {
         noop_fold_pat(p, self)
     }
@@ -354,11 +358,17 @@ pub fn noop_fold_arm<T: Folder>(Arm {attrs, pats, guard, body}: Arm,
     Arm {
         attrs: fold_attrs(attrs, fld),
         pats: pats.move_map(|x| fld.fold_pat(x)),
-        guard: guard.map(|x| fld.fold_expr(x)),
+        guard: guard.map(|x| fld.fold_guard(x)),
         body: fld.fold_expr(body),
     }
 }
 
+pub fn noop_fold_guard<T: Folder>(g: Guard, fld: &mut T) -> Guard {
+    match g {
+        Guard::If(e) => Guard::If(fld.fold_expr(e)),
+    }
+}
+
 pub fn noop_fold_ty_binding<T: Folder>(b: TypeBinding, fld: &mut T) -> TypeBinding {
     TypeBinding {
         id: fld.new_id(b.id),