rustc: Move path_to_ident to ast_util
This commit is contained in:
parent
c492a183d7
commit
85d67723ee
9 changed files with 11 additions and 9 deletions
|
@ -25,6 +25,8 @@ fn path_name(p: @path) -> str { path_name_i(p.idents) }
|
|||
|
||||
fn path_name_i(idents: [ident]) -> str { str::connect(idents, "::") }
|
||||
|
||||
fn path_to_ident(p: @path) -> ident { vec::last(p.idents) }
|
||||
|
||||
fn local_def(id: node_id) -> def_id { {crate: local_crate, node: id} }
|
||||
|
||||
pure fn is_local(did: ast::def_id) -> bool { did.crate == local_crate }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import syntax::{ast, ast_util};
|
||||
import ast_util::path_to_ident;
|
||||
import ast::{ident, fn_ident, node_id};
|
||||
import syntax::codemap::span;
|
||||
import syntax::visit;
|
||||
|
|
|
@ -4,6 +4,7 @@ import syntax::ast::*;
|
|||
import syntax::print::pprust;
|
||||
import syntax::ast_util;
|
||||
import middle::pat_util::*;
|
||||
import syntax::ast_util::path_to_ident;
|
||||
import syntax::ast_util::inlined_item_methods;
|
||||
import syntax::{visit, codemap};
|
||||
import driver::session::session;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import syntax::ast::*;
|
||||
import syntax::ast_util;
|
||||
import syntax::ast_util::path_to_ident;
|
||||
import syntax::ast_util::respan;
|
||||
import syntax::fold;
|
||||
import syntax::fold::*;
|
||||
|
@ -9,7 +10,6 @@ import std::map::hashmap;
|
|||
export walk_pat;
|
||||
export pat_binding_ids, pat_bindings, pat_id_map;
|
||||
export pat_is_variant;
|
||||
export path_to_ident;
|
||||
|
||||
type pat_id_map = std::map::hashmap<str, node_id>;
|
||||
|
||||
|
@ -68,5 +68,3 @@ fn pat_binding_ids(dm: resolve::def_map, pat: @pat) -> [node_id] {
|
|||
pat_bindings(dm, pat) {|b_id, _sp, _pt| found += [b_id]; };
|
||||
ret found;
|
||||
}
|
||||
|
||||
fn path_to_ident(p: @path) -> ident { vec::last(p.idents) }
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import syntax::{ast, ast_util, codemap};
|
||||
import syntax::ast::*;
|
||||
import ast::{ident, fn_ident, def, def_id, node_id};
|
||||
import syntax::ast_util::{local_def, def_id_of_def, class_item_ident};
|
||||
import syntax::ast_util::{local_def, def_id_of_def,
|
||||
class_item_ident, path_to_ident};
|
||||
import pat_util::*;
|
||||
|
||||
import syntax::attr;
|
||||
|
|
|
@ -6,7 +6,7 @@ import build::*;
|
|||
import base::*;
|
||||
import syntax::ast;
|
||||
import syntax::ast_util;
|
||||
import syntax::ast_util::{dummy_sp};
|
||||
import syntax::ast_util::{dummy_sp, path_to_ident};
|
||||
import syntax::ast::def_id;
|
||||
import syntax::codemap::span;
|
||||
import syntax::print::pprust::pat_to_str;
|
||||
|
|
|
@ -22,8 +22,7 @@ import session::session;
|
|||
import syntax::attr;
|
||||
import back::{link, abi, upcall};
|
||||
import syntax::{ast, ast_util, codemap};
|
||||
import ast_util::inlined_item_methods;
|
||||
import ast_util::local_def;
|
||||
import ast_util::{inlined_item_methods, local_def, path_to_ident};
|
||||
import syntax::visit;
|
||||
import syntax::codemap::span;
|
||||
import syntax::print::pprust::{expr_to_str, stmt_to_str, path_to_str};
|
||||
|
|
|
@ -648,7 +648,7 @@ fn create_local_var(bcx: block, local: @ast::local)
|
|||
}
|
||||
|
||||
let name = alt local.node.pat.node {
|
||||
ast::pat_ident(pth, _) { pat_util::path_to_ident(pth) }
|
||||
ast::pat_ident(pth, _) { ast_util::path_to_ident(pth) }
|
||||
// FIXME this should be handled
|
||||
_ { fail "no single variable name for local"; }
|
||||
};
|
||||
|
|
|
@ -154,7 +154,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
|
|||
let vid = lookup_local(pcx.fcx, pat.span, pat.id);
|
||||
let mut typ = ty::mk_var(tcx, vid);
|
||||
demand::suptype(pcx.fcx, pat.span, expected, typ);
|
||||
let canon_id = pcx.map.get(pat_util::path_to_ident(name));
|
||||
let canon_id = pcx.map.get(ast_util::path_to_ident(name));
|
||||
if canon_id != pat.id {
|
||||
let tv_id = lookup_local(pcx.fcx, pat.span, canon_id);
|
||||
let ct = ty::mk_var(tcx, tv_id);
|
||||
|
|
Loading…
Reference in a new issue