rustc: Move path_to_str to front::ast
This commit is contained in:
parent
4e59b0be54
commit
d39c59ae41
@ -598,6 +598,19 @@ fn ternary_to_if(&@expr e) -> @ast::expr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Path stringification
|
||||||
|
fn path_to_str(&ast::path pth) -> str {
|
||||||
|
auto result = str::connect(pth.node.idents, "::");
|
||||||
|
if (vec::len[@ast::ty](pth.node.types) > 0u) {
|
||||||
|
fn f(&@ast::ty t) -> str { ret pretty::pprust::ty_to_str(*t); }
|
||||||
|
result += "[";
|
||||||
|
result += str::connect(vec::map(f, pth.node.types), ",");
|
||||||
|
result += "]";
|
||||||
|
}
|
||||||
|
ret result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// mode: rust
|
// mode: rust
|
||||||
|
@ -232,7 +232,7 @@ fn enc_ty_fn(&io::writer w, &@ctxt cx, &ty::arg[] args, &ty::t out,
|
|||||||
|
|
||||||
}
|
}
|
||||||
fn enc_constr(&io::writer w, &@ctxt cx, &@ty::constr_def c) {
|
fn enc_constr(&io::writer w, &@ctxt cx, &@ty::constr_def c) {
|
||||||
w.write_str(ty::path_to_str(c.node.path));
|
w.write_str(path_to_str(c.node.path));
|
||||||
w.write_char('(');
|
w.write_char('(');
|
||||||
w.write_str(cx.ds(c.node.id));
|
w.write_str(cx.ds(c.node.id));
|
||||||
w.write_char('|');
|
w.write_char('|');
|
||||||
|
@ -423,7 +423,7 @@ fn resolve_constr(@env e, node_id id, &@ast::constr c, &scopes sc,
|
|||||||
case (_) {
|
case (_) {
|
||||||
e.sess.span_err(c.span,
|
e.sess.span_err(c.span,
|
||||||
"Non-predicate in constraint: " +
|
"Non-predicate in constraint: " +
|
||||||
ty::path_to_str(c.node.path));
|
ast::path_to_str(c.node.path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import front::ast::def_id;
|
|||||||
import front::ast::constr_arg_general;
|
import front::ast::constr_arg_general;
|
||||||
import front::ast::mutability;
|
import front::ast::mutability;
|
||||||
import front::ast::controlflow;
|
import front::ast::controlflow;
|
||||||
|
import front::ast::path_to_str;
|
||||||
import metadata::creader;
|
import metadata::creader;
|
||||||
import metadata::decoder;
|
import metadata::decoder;
|
||||||
import util::common::*;
|
import util::common::*;
|
||||||
@ -101,7 +102,6 @@ export node_type_table;
|
|||||||
export pat_node_id;
|
export pat_node_id;
|
||||||
export pat_ty;
|
export pat_ty;
|
||||||
export cname;
|
export cname;
|
||||||
export path_to_str;
|
|
||||||
export rename;
|
export rename;
|
||||||
export ret_ty_of_fn;
|
export ret_ty_of_fn;
|
||||||
export ret_ty_of_fn_ty;
|
export ret_ty_of_fn_ty;
|
||||||
@ -632,19 +632,6 @@ fn cname(&ctxt cx, &t typ) -> option::t[str] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Stringification
|
|
||||||
fn path_to_str(&ast::path pth) -> str {
|
|
||||||
auto result = str::connect(pth.node.idents, "::");
|
|
||||||
if (vec::len[@ast::ty](pth.node.types) > 0u) {
|
|
||||||
fn f(&@ast::ty t) -> str { ret pretty::pprust::ty_to_str(*t); }
|
|
||||||
result += "[";
|
|
||||||
result += str::connect(vec::map(f, pth.node.types), ",");
|
|
||||||
result += "]";
|
|
||||||
}
|
|
||||||
ret result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Type folds
|
// Type folds
|
||||||
type ty_walk = fn(t) ;
|
type ty_walk = fn(t) ;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
import front::ast;
|
import front::ast;
|
||||||
import front::ast::mutability;
|
import front::ast::mutability;
|
||||||
import front::ast::local_def;
|
import front::ast::local_def;
|
||||||
|
import front::ast::path_to_str;
|
||||||
import metadata::decoder;
|
import metadata::decoder;
|
||||||
import driver::session;
|
import driver::session;
|
||||||
import util::common;
|
import util::common;
|
||||||
@ -22,7 +23,6 @@ import middle::ty::mo_val;
|
|||||||
import middle::ty::mo_alias;
|
import middle::ty::mo_alias;
|
||||||
import middle::ty::node_type_table;
|
import middle::ty::node_type_table;
|
||||||
import middle::ty::pat_ty;
|
import middle::ty::pat_ty;
|
||||||
import middle::ty::path_to_str;
|
|
||||||
import middle::ty::ty_param_substs_opt_and_ty;
|
import middle::ty::ty_param_substs_opt_and_ty;
|
||||||
import pretty::ppaux::ty_to_str;
|
import pretty::ppaux::ty_to_str;
|
||||||
import middle::ty::ty_param_count_and_ty;
|
import middle::ty::ty_param_count_and_ty;
|
||||||
|
@ -379,12 +379,12 @@ const uint default_columns = 78u;
|
|||||||
fn uint_to_str(&uint i) -> str { ret uistr(i); }
|
fn uint_to_str(&uint i) -> str { ret uistr(i); }
|
||||||
|
|
||||||
fn constr_to_str(&@constr_def c) -> str {
|
fn constr_to_str(&@constr_def c) -> str {
|
||||||
ret path_to_str(c.node.path) +
|
ret ast::path_to_str(c.node.path) +
|
||||||
constr_args_to_str(uint_to_str, c.node.args);
|
constr_args_to_str(uint_to_str, c.node.args);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ast_constr_to_str(&@front::ast::constr c) -> str {
|
fn ast_constr_to_str(&@front::ast::constr c) -> str {
|
||||||
ret path_to_str(c.node.path) +
|
ret ast::path_to_str(c.node.path) +
|
||||||
constr_args_to_str(uint_to_str, c.node.args);
|
constr_args_to_str(uint_to_str, c.node.args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user