From 21f86855ddd8231b28b2c89bbcf7f9a7ed1324a4 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 31 Jan 2014 12:46:23 -0800 Subject: [PATCH] librustc: De-`@str` `ident()` and `str_of()` --- src/librustc/driver/session.rs | 8 +++++--- src/librustc/middle/check_match.rs | 6 +++--- src/librustc/middle/trans/common.rs | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index eceed2422b6..cebc25c4845 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -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... diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 228dbb01755..d402305401e 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -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 } } diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index a17ad98e426..04789b9ca70 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -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 { -- 2.44.0