Refactor tyencode::ty_str to not require a tyencode::ctxt

All users were constructing the context the same way.
This commit is contained in:
Brian Anderson 2011-07-07 12:43:08 -07:00
parent 4304f8d4f6
commit 73963eae9a
3 changed files with 6 additions and 10 deletions

View File

@ -401,17 +401,13 @@ fn symbol_hash(ty::ctxt tcx, sha1 sha, &ty::t t,
// NB: do *not* use abbrevs here as we want the symbol names
// to be independent of one another in the crate.
auto cx =
@rec(ds=metadata::encoder::def_to_str,
tcx=tcx,
abbrevs=metadata::tyencode::ac_no_abbrevs);
sha.reset();
sha.input_str(link_meta.name);
sha.input_str("-");
// FIXME: This wants to be link_meta.meta_hash
sha.input_str(link_meta.name);
sha.input_str("-");
sha.input_str(metadata::tyencode::ty_str(cx, t));
sha.input_str(metadata::tyencode::ty_str(tcx, t));
auto hash = truncated_sha1_result(sha);
// Prefix with _ so that it never blends into adjacent digits

View File

@ -36,8 +36,10 @@ fn cx_uses_abbrevs(&@ctxt cx) -> bool {
case (ac_use_abbrevs(_)) { ret true; }
}
}
fn ty_str(&@ctxt cx, &ty::t t) -> str {
assert (!cx_uses_abbrevs(cx));
fn ty_str(&ty::ctxt tcx, &ty::t t) -> str {
auto cx = @rec(ds = encoder::def_to_str,
tcx = tcx,
abbrevs = metadata::tyencode::ac_no_abbrevs);
auto sw = io::string_writer();
enc_ty(sw.get_writer(), cx, t);
ret sw.get_str();

View File

@ -151,9 +151,7 @@ fn ty_to_str(&ctxt cx, &t typ) -> str {
}
fn ty_to_short_str(&ctxt cx, t typ) -> str {
auto f = metadata::encoder::def_to_str;
auto ecx = @rec(ds=f, tcx=cx, abbrevs=metadata::tyencode::ac_no_abbrevs);
auto s = metadata::tyencode::ty_str(ecx, typ);
auto s = metadata::tyencode::ty_str(cx, typ);
if (str::byte_len(s) >= 32u) { s = str::substr(s, 0u, 32u); }
ret s;
}