diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index ca25fb65b21..ce3bf568cd8 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -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: // mode: rust diff --git a/src/comp/metadata/tyencode.rs b/src/comp/metadata/tyencode.rs index f8a2c660c3d..a9090c3624c 100644 --- a/src/comp/metadata/tyencode.rs +++ b/src/comp/metadata/tyencode.rs @@ -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) { - w.write_str(ty::path_to_str(c.node.path)); + w.write_str(path_to_str(c.node.path)); w.write_char('('); w.write_str(cx.ds(c.node.id)); w.write_char('|'); diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index eb7d3d4dd82..f6a5b6413d0 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -423,7 +423,7 @@ fn resolve_constr(@env e, node_id id, &@ast::constr c, &scopes sc, case (_) { e.sess.span_err(c.span, "Non-predicate in constraint: " + - ty::path_to_str(c.node.path)); + ast::path_to_str(c.node.path)); } } } diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 5e8b79df767..1b7e7878964 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -18,6 +18,7 @@ import front::ast::def_id; import front::ast::constr_arg_general; import front::ast::mutability; import front::ast::controlflow; +import front::ast::path_to_str; import metadata::creader; import metadata::decoder; import util::common::*; @@ -101,7 +102,6 @@ export node_type_table; export pat_node_id; export pat_ty; export cname; -export path_to_str; export rename; export ret_ty_of_fn; 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 ty_walk = fn(t) ; diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 1a2670f8249..c46c885ab6d 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -2,6 +2,7 @@ import front::ast; import front::ast::mutability; import front::ast::local_def; +import front::ast::path_to_str; import metadata::decoder; import driver::session; import util::common; @@ -22,7 +23,6 @@ import middle::ty::mo_val; import middle::ty::mo_alias; import middle::ty::node_type_table; import middle::ty::pat_ty; -import middle::ty::path_to_str; import middle::ty::ty_param_substs_opt_and_ty; import pretty::ppaux::ty_to_str; import middle::ty::ty_param_count_and_ty; diff --git a/src/comp/pretty/ppaux.rs b/src/comp/pretty/ppaux.rs index fbe4ea9034c..396d37a8090 100644 --- a/src/comp/pretty/ppaux.rs +++ b/src/comp/pretty/ppaux.rs @@ -379,12 +379,12 @@ const uint default_columns = 78u; fn uint_to_str(&uint i) -> str { ret uistr(i); } 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); } 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); }