Skip to content

Commit 0f3a4e1

Browse files
pcwaltonhuonw
authored andcommitted
librustc: De-@str type short names
1 parent e9ce855 commit 0f3a4e1

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/librustc/metadata/tyencode.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub struct ctxt {
4545
pub struct ty_abbrev {
4646
pos: uint,
4747
len: uint,
48-
s: @str
48+
s: ~str
4949
}
5050

5151
pub enum abbrev_ctxt {
@@ -65,19 +65,21 @@ pub fn enc_ty(w: &mut MemWriter, cx: @ctxt, t: ty::t) {
6565
let short_names_cache = cx.tcx.short_names_cache.borrow();
6666
result_str_opt = short_names_cache.get()
6767
.find(&t)
68-
.map(|result| *result);
68+
.map(|result| {
69+
(*result).clone()
70+
});
6971
}
7072
let result_str = match result_str_opt {
7173
Some(s) => s,
7274
None => {
7375
let wr = &mut MemWriter::new();
7476
enc_sty(wr, cx, &ty::get(t).sty);
75-
let s = str::from_utf8(wr.get_ref()).unwrap().to_managed();
77+
let s = str::from_utf8(wr.get_ref()).unwrap();
7678
let mut short_names_cache = cx.tcx
7779
.short_names_cache
7880
.borrow_mut();
79-
short_names_cache.get().insert(t, s);
80-
s
81+
short_names_cache.get().insert(t, s.to_str());
82+
s.to_str()
8183
}
8284
};
8385
w.write(result_str.as_bytes());
@@ -103,7 +105,7 @@ pub fn enc_ty(w: &mut MemWriter, cx: @ctxt, t: ty::t) {
103105
let abbrev_len = 3 + estimate_sz(pos) + estimate_sz(len);
104106
if abbrev_len < len {
105107
// I.e. it's actually an abbreviation.
106-
let s = format!("\\#{:x}:{:x}\\#", pos, len).to_managed();
108+
let s = format!("\\#{:x}:{:x}\\#", pos, len);
107109
let a = ty_abbrev { pos: pos as uint,
108110
len: len as uint,
109111
s: s };

src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ pub struct ctxt_ {
291291
freevars: RefCell<freevars::freevar_map>,
292292
tcache: type_cache,
293293
rcache: creader_cache,
294-
short_names_cache: RefCell<HashMap<t, @str>>,
294+
short_names_cache: RefCell<HashMap<t, ~str>>,
295295
needs_unwind_cleanup_cache: RefCell<HashMap<t, bool>>,
296296
tc_cache: RefCell<HashMap<uint, TypeContents>>,
297297
ast_ty_to_ty_cache: RefCell<HashMap<NodeId, ast_ty_to_ty_cache_entry>>,

0 commit comments

Comments
 (0)