about summary refs log tree commit diff
path: root/src/librustsyntax
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-05-21 23:17:28 -0700
committerBrian Anderson <banderson@mozilla.com>2012-05-21 23:22:08 -0700
commit47bb1185f2ae17e6a8b24da533c4d2f548e1e808 (patch)
treef2b9024f26c6a41b1e65ef6d76f965acf8d28cd9 /src/librustsyntax
parentdf532e7f1b56d9b2a52a0edb9a84c9b9246dd8df (diff)
downloadrust-47bb1185f2ae17e6a8b24da533c4d2f548e1e808.tar.gz
rust-47bb1185f2ae17e6a8b24da533c4d2f548e1e808.zip
rustc: Move walk_pat to ast_util
This will allow ast_map to move to the syntax crate
Diffstat (limited to 'src/librustsyntax')
-rw-r--r--src/librustsyntax/ast_util.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/librustsyntax/ast_util.rs b/src/librustsyntax/ast_util.rs
index 2f0e4447352..211414ac7d4 100644
--- a/src/librustsyntax/ast_util.rs
+++ b/src/librustsyntax/ast_util.rs
@@ -530,6 +530,18 @@ pure fn is_item_impl(item: @ast::item) -> bool {
     }
 }
 
+fn walk_pat(pat: @pat, it: fn(@pat)) {
+    it(pat);
+    alt pat.node {
+      pat_ident(pth, some(p)) { walk_pat(p, it); }
+      pat_rec(fields, _) { for fields.each {|f| walk_pat(f.pat, it); } }
+      pat_enum(_, some(s)) | pat_tup(s) { for s.each {|p| walk_pat(p, it); } }
+      pat_box(s) | pat_uniq(s) { walk_pat(s, it); }
+      pat_wild | pat_lit(_) | pat_range(_, _) | pat_ident(_, _)
+        | pat_enum(_, _) {}
+    }
+}
+
 // Local Variables:
 // mode: rust
 // fill-column: 78;