rustc: Move walk_pat to ast_util
This will allow ast_map to move to the syntax crate
This commit is contained in:
parent
df532e7f1b
commit
47bb1185f2
@ -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;
|
||||
|
@ -154,7 +154,7 @@ fn map_block(b: blk, cx: ctx, v: vt) {
|
||||
}
|
||||
|
||||
fn number_pat(cx: ctx, pat: @pat) {
|
||||
pat_util::walk_pat(pat) {|p|
|
||||
ast_util::walk_pat(pat) {|p|
|
||||
alt p.node {
|
||||
pat_ident(_, _) {
|
||||
cx.map.insert(p.id, node_local(cx.local_id));
|
||||
|
@ -1,13 +1,11 @@
|
||||
import syntax::ast::*;
|
||||
import syntax::ast_util;
|
||||
import syntax::ast_util::path_to_ident;
|
||||
import syntax::ast_util::respan;
|
||||
import syntax::ast_util::{path_to_ident, respan, walk_pat};
|
||||
import syntax::fold;
|
||||
import syntax::fold::*;
|
||||
import syntax::codemap::span;
|
||||
import std::map::hashmap;
|
||||
|
||||
export walk_pat;
|
||||
export pat_binding_ids, pat_bindings, pat_id_map;
|
||||
export pat_is_variant;
|
||||
|
||||
@ -51,18 +49,6 @@ fn pat_bindings(dm: resolve::def_map, pat: @pat,
|
||||
}
|
||||
}
|
||||
|
||||
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(_, _) {}
|
||||
}
|
||||
}
|
||||
|
||||
fn pat_binding_ids(dm: resolve::def_map, pat: @pat) -> [node_id] {
|
||||
let mut found = [];
|
||||
pat_bindings(dm, pat) {|b_id, _sp, _pt| found += [b_id]; };
|
||||
|
@ -688,7 +688,7 @@ fn visit_local_with_scope(e: @env, loc: @local, &&sc: scopes, v:vt<scopes>) {
|
||||
// scope. We disallow this, in order to make alt patterns consisting of a
|
||||
// single identifier unambiguous (does the pattern "foo" refer to enum
|
||||
// foo, or is it binding a new name foo?)
|
||||
pat_util::walk_pat(loc.node.pat) { |p|
|
||||
ast_util::walk_pat(loc.node.pat) { |p|
|
||||
alt p.node {
|
||||
pat_ident(path, _) {
|
||||
alt lookup_in_scope(*e, sc, loc.span, path_to_ident(path),
|
||||
|
Loading…
x
Reference in New Issue
Block a user