]> git.lizzy.rs Git - rust.git/commitdiff
librustc: De-`@str` type short names
authorPatrick Walton <pcwalton@mimiga.net>
Fri, 31 Jan 2014 20:36:00 +0000 (12:36 -0800)
committerHuon Wilson <dbau.pp+github@gmail.com>
Sat, 1 Feb 2014 14:44:49 +0000 (01:44 +1100)
src/librustc/metadata/tyencode.rs
src/librustc/middle/ty.rs

index 9da19d666673f1ab3ba2f8258421da0b047288df..b7977f9d64329d0f59f5d044f081fc34a66672d1 100644 (file)
@@ -45,7 +45,7 @@ pub struct ctxt {
 pub struct ty_abbrev {
     pos: uint,
     len: uint,
-    s: @str
+    s: ~str
 }
 
 pub enum abbrev_ctxt {
@@ -65,19 +65,21 @@ pub fn enc_ty(w: &mut MemWriter, cx: @ctxt, t: ty::t) {
               let short_names_cache = cx.tcx.short_names_cache.borrow();
               result_str_opt = short_names_cache.get()
                                                 .find(&t)
-                                                .map(|result| *result);
+                                                .map(|result| {
+                                                    (*result).clone()
+                                                });
           }
           let result_str = match result_str_opt {
             Some(s) => s,
             None => {
                 let wr = &mut MemWriter::new();
                 enc_sty(wr, cx, &ty::get(t).sty);
-                let s = str::from_utf8(wr.get_ref()).unwrap().to_managed();
+                let s = str::from_utf8(wr.get_ref()).unwrap();
                 let mut short_names_cache = cx.tcx
                                               .short_names_cache
                                               .borrow_mut();
-                short_names_cache.get().insert(t, s);
-                s
+                short_names_cache.get().insert(t, s.to_str());
+                s.to_str()
             }
           };
           w.write(result_str.as_bytes());
@@ -103,7 +105,7 @@ fn estimate_sz(u: u64) -> u64 {
           let abbrev_len = 3 + estimate_sz(pos) + estimate_sz(len);
           if abbrev_len < len {
               // I.e. it's actually an abbreviation.
-              let s = format!("\\#{:x}:{:x}\\#", pos, len).to_managed();
+              let s = format!("\\#{:x}:{:x}\\#", pos, len);
               let a = ty_abbrev { pos: pos as uint,
                                   len: len as uint,
                                   s: s };
index 681eabb797dc27939e4efe9c420cf07a874edda0..93bfe9c51e1dd1f40bc8de68e0fbc7d9690c5cf9 100644 (file)
@@ -291,7 +291,7 @@ pub struct ctxt_ {
     freevars: RefCell<freevars::freevar_map>,
     tcache: type_cache,
     rcache: creader_cache,
-    short_names_cache: RefCell<HashMap<t, @str>>,
+    short_names_cache: RefCell<HashMap<t, ~str>>,
     needs_unwind_cleanup_cache: RefCell<HashMap<t, bool>>,
     tc_cache: RefCell<HashMap<uint, TypeContents>>,
     ast_ty_to_ty_cache: RefCell<HashMap<NodeId, ast_ty_to_ty_cache_entry>>,