Skip to content

Commit 47bb118

Browse files
committed
rustc: Move walk_pat to ast_util
This will allow ast_map to move to the syntax crate
1 parent df532e7 commit 47bb118

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

src/librustsyntax/ast_util.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,18 @@ pure fn is_item_impl(item: @ast::item) -> bool {
530530
}
531531
}
532532

533+
fn walk_pat(pat: @pat, it: fn(@pat)) {
534+
it(pat);
535+
alt pat.node {
536+
pat_ident(pth, some(p)) { walk_pat(p, it); }
537+
pat_rec(fields, _) { for fields.each {|f| walk_pat(f.pat, it); } }
538+
pat_enum(_, some(s)) | pat_tup(s) { for s.each {|p| walk_pat(p, it); } }
539+
pat_box(s) | pat_uniq(s) { walk_pat(s, it); }
540+
pat_wild | pat_lit(_) | pat_range(_, _) | pat_ident(_, _)
541+
| pat_enum(_, _) {}
542+
}
543+
}
544+
533545
// Local Variables:
534546
// mode: rust
535547
// fill-column: 78;

src/rustc/middle/ast_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn map_block(b: blk, cx: ctx, v: vt) {
154154
}
155155

156156
fn number_pat(cx: ctx, pat: @pat) {
157-
pat_util::walk_pat(pat) {|p|
157+
ast_util::walk_pat(pat) {|p|
158158
alt p.node {
159159
pat_ident(_, _) {
160160
cx.map.insert(p.id, node_local(cx.local_id));

src/rustc/middle/pat_util.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import syntax::ast::*;
22
import syntax::ast_util;
3-
import syntax::ast_util::path_to_ident;
4-
import syntax::ast_util::respan;
3+
import syntax::ast_util::{path_to_ident, respan, walk_pat};
54
import syntax::fold;
65
import syntax::fold::*;
76
import syntax::codemap::span;
87
import std::map::hashmap;
98

10-
export walk_pat;
119
export pat_binding_ids, pat_bindings, pat_id_map;
1210
export pat_is_variant;
1311

@@ -51,18 +49,6 @@ fn pat_bindings(dm: resolve::def_map, pat: @pat,
5149
}
5250
}
5351

54-
fn walk_pat(pat: @pat, it: fn(@pat)) {
55-
it(pat);
56-
alt pat.node {
57-
pat_ident(pth, some(p)) { walk_pat(p, it); }
58-
pat_rec(fields, _) { for fields.each {|f| walk_pat(f.pat, it); } }
59-
pat_enum(_, some(s)) | pat_tup(s) { for s.each {|p| walk_pat(p, it); } }
60-
pat_box(s) | pat_uniq(s) { walk_pat(s, it); }
61-
pat_wild | pat_lit(_) | pat_range(_, _) | pat_ident(_, _)
62-
| pat_enum(_, _) {}
63-
}
64-
}
65-
6652
fn pat_binding_ids(dm: resolve::def_map, pat: @pat) -> [node_id] {
6753
let mut found = [];
6854
pat_bindings(dm, pat) {|b_id, _sp, _pt| found += [b_id]; };

src/rustc/middle/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ fn visit_local_with_scope(e: @env, loc: @local, &&sc: scopes, v:vt<scopes>) {
688688
// scope. We disallow this, in order to make alt patterns consisting of a
689689
// single identifier unambiguous (does the pattern "foo" refer to enum
690690
// foo, or is it binding a new name foo?)
691-
pat_util::walk_pat(loc.node.pat) { |p|
691+
ast_util::walk_pat(loc.node.pat) { |p|
692692
alt p.node {
693693
pat_ident(path, _) {
694694
alt lookup_in_scope(*e, sc, loc.span, path_to_ident(path),

0 commit comments

Comments
 (0)