]> git.lizzy.rs Git - rust.git/commitdiff
librustc: De-`@str` `ident()` and `str_of()`
authorPatrick Walton <pcwalton@mimiga.net>
Fri, 31 Jan 2014 20:46:23 +0000 (12:46 -0800)
committerHuon Wilson <dbau.pp+github@gmail.com>
Sat, 1 Feb 2014 14:44:49 +0000 (01:44 +1100)
src/librustc/driver/session.rs
src/librustc/middle/check_match.rs
src/librustc/middle/trans/common.rs

index eceed2422b62be40e899c75fd531101767921be8..cebc25c4845d4ba8d9ac17466d8cb6ee9a09c7a9 100644 (file)
@@ -352,9 +352,11 @@ pub fn no_landing_pads(&self) -> bool {
         self.debugging_opt(NO_LANDING_PADS)
     }
 
-    // pointless function, now...
-    pub fn str_of(&self, id: ast::Ident) -> @str {
-        token::ident_to_str(&id)
+    // DEPRECATED. This function results in a lot of allocations when they
+    // are not necessary.
+    pub fn str_of(&self, id: ast::Ident) -> ~str {
+        let string = token::get_ident(id.name);
+        string.get().to_str()
     }
 
     // pointless function, now...
index 228dbb0175596a794496717b62f8011a6831514b..d402305401eb96ecc103d80940bf72050278090f 100644 (file)
@@ -176,8 +176,8 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@Pat]) {
             match ty::get(ty).sty {
                 ty::ty_bool => {
                     match *ctor {
-                        val(const_bool(true)) => Some(@"true"),
-                        val(const_bool(false)) => Some(@"false"),
+                        val(const_bool(true)) => Some(~"true"),
+                        val(const_bool(false)) => Some(~"false"),
                         _ => None
                     }
                 }
@@ -197,7 +197,7 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@Pat]) {
                 }
                 ty::ty_unboxed_vec(..) | ty::ty_vec(..) => {
                     match *ctor {
-                        vec(n) => Some(format!("vectors of length {}", n).to_managed()),
+                        vec(n) => Some(format!("vectors of length {}", n)),
                         _ => None
                     }
                 }
index a17ad98e42666154bb2a5de53731edbcf3c72e27..04789b9ca706d955edd4dc3c9dd1131746bfe5f6 100644 (file)
@@ -446,8 +446,9 @@ pub fn tcx(&self) -> ty::ctxt {
     }
     pub fn sess(&self) -> Session { self.fcx.ccx.sess }
 
-    pub fn ident(&self, ident: Ident) -> @str {
-        token::ident_to_str(&ident)
+    pub fn ident(&self, ident: Ident) -> ~str {
+        let string = token::get_ident(ident.name);
+        string.get().to_str()
     }
 
     pub fn node_id_to_str(&self, id: ast::NodeId) -> ~str {