Skip to content

Commit 73963ea

Browse files
committed
Refactor tyencode::ty_str to not require a tyencode::ctxt
All users were constructing the context the same way.
1 parent 4304f8d commit 73963ea

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

src/comp/back/link.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,17 +401,13 @@ fn symbol_hash(ty::ctxt tcx, sha1 sha, &ty::t t,
401401
// NB: do *not* use abbrevs here as we want the symbol names
402402
// to be independent of one another in the crate.
403403

404-
auto cx =
405-
@rec(ds=metadata::encoder::def_to_str,
406-
tcx=tcx,
407-
abbrevs=metadata::tyencode::ac_no_abbrevs);
408404
sha.reset();
409405
sha.input_str(link_meta.name);
410406
sha.input_str("-");
411407
// FIXME: This wants to be link_meta.meta_hash
412408
sha.input_str(link_meta.name);
413409
sha.input_str("-");
414-
sha.input_str(metadata::tyencode::ty_str(cx, t));
410+
sha.input_str(metadata::tyencode::ty_str(tcx, t));
415411
auto hash = truncated_sha1_result(sha);
416412
// Prefix with _ so that it never blends into adjacent digits
417413

src/comp/metadata/tyencode.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ fn cx_uses_abbrevs(&@ctxt cx) -> bool {
3636
case (ac_use_abbrevs(_)) { ret true; }
3737
}
3838
}
39-
fn ty_str(&@ctxt cx, &ty::t t) -> str {
40-
assert (!cx_uses_abbrevs(cx));
39+
fn ty_str(&ty::ctxt tcx, &ty::t t) -> str {
40+
auto cx = @rec(ds = encoder::def_to_str,
41+
tcx = tcx,
42+
abbrevs = metadata::tyencode::ac_no_abbrevs);
4143
auto sw = io::string_writer();
4244
enc_ty(sw.get_writer(), cx, t);
4345
ret sw.get_str();

src/comp/util/ppaux.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@ fn ty_to_str(&ctxt cx, &t typ) -> str {
151151
}
152152

153153
fn ty_to_short_str(&ctxt cx, t typ) -> str {
154-
auto f = metadata::encoder::def_to_str;
155-
auto ecx = @rec(ds=f, tcx=cx, abbrevs=metadata::tyencode::ac_no_abbrevs);
156-
auto s = metadata::tyencode::ty_str(ecx, typ);
154+
auto s = metadata::tyencode::ty_str(cx, typ);
157155
if (str::byte_len(s) >= 32u) { s = str::substr(s, 0u, 32u); }
158156
ret s;
159157
}

0 commit comments

Comments
 (0)