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

index 6a1fa488121bb58ffff60a3ce3934f22de3c6b8c..ed583f919ca14c93bc16b0cec541c5eebb9274cf 100644 (file)
 use syntax::ast::*;
 use syntax::codemap::Span;
 use syntax::parse::token::special_idents;
+use syntax::parse::token;
 use syntax::print::pprust::{expr_to_str, block_to_str};
 use syntax::{visit, ast_util};
 use syntax::visit::{Visitor, FnKind};
@@ -332,13 +333,14 @@ pub fn variable(&self, node_id: NodeId, span: Span) -> Variable {
         }
     }
 
-    pub fn variable_name(&self, var: Variable) -> @str {
+    pub fn variable_name(&self, var: Variable) -> ~str {
         let var_kinds = self.var_kinds.borrow();
         match var_kinds.get()[var.get()] {
             Local(LocalInfo { ident: nm, .. }) | Arg(_, nm) => {
-                self.tcx.sess.str_of(nm)
+                let string = token::get_ident(nm.name);
+                string.get().to_str()
             },
-            ImplicitRet => @"<implicit-ret>"
+            ImplicitRet => ~"<implicit-ret>"
         }
     }
 
@@ -1669,7 +1671,7 @@ pub fn report_illegal_read(&self,
         }
     }
 
-    pub fn should_warn(&self, var: Variable) -> Option<@str> {
+    pub fn should_warn(&self, var: Variable) -> Option<~str> {
         let name = self.ir.variable_name(var);
         if name.len() == 0 || name[0] == ('_' as u8) { None } else { Some(name) }
     }