Skip to content

Commit 21f8685

Browse files
pcwaltonhuonw
authored andcommitted
librustc: De-@str ident() and str_of()
1 parent 19d4ea1 commit 21f8685

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/librustc/driver/session.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,11 @@ impl Session_ {
352352
self.debugging_opt(NO_LANDING_PADS)
353353
}
354354

355-
// pointless function, now...
356-
pub fn str_of(&self, id: ast::Ident) -> @str {
357-
token::ident_to_str(&id)
355+
// DEPRECATED. This function results in a lot of allocations when they
356+
// are not necessary.
357+
pub fn str_of(&self, id: ast::Ident) -> ~str {
358+
let string = token::get_ident(id.name);
359+
string.get().to_str()
358360
}
359361

360362
// pointless function, now...

src/librustc/middle/check_match.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@Pat]) {
176176
match ty::get(ty).sty {
177177
ty::ty_bool => {
178178
match *ctor {
179-
val(const_bool(true)) => Some(@"true"),
180-
val(const_bool(false)) => Some(@"false"),
179+
val(const_bool(true)) => Some(~"true"),
180+
val(const_bool(false)) => Some(~"false"),
181181
_ => None
182182
}
183183
}
@@ -197,7 +197,7 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@Pat]) {
197197
}
198198
ty::ty_unboxed_vec(..) | ty::ty_vec(..) => {
199199
match *ctor {
200-
vec(n) => Some(format!("vectors of length {}", n).to_managed()),
200+
vec(n) => Some(format!("vectors of length {}", n)),
201201
_ => None
202202
}
203203
}

src/librustc/middle/trans/common.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,9 @@ impl<'a> Block<'a> {
446446
}
447447
pub fn sess(&self) -> Session { self.fcx.ccx.sess }
448448

449-
pub fn ident(&self, ident: Ident) -> @str {
450-
token::ident_to_str(&ident)
449+
pub fn ident(&self, ident: Ident) -> ~str {
450+
let string = token::get_ident(ident.name);
451+
string.get().to_str()
451452
}
452453

453454
pub fn node_id_to_str(&self, id: ast::NodeId) -> ~str {

0 commit comments

Comments
 (0)