diff --git a/src/librustc/front/feature_gate.rs b/src/librustc/front/feature_gate.rs index c6550ec7c6e8..de5a7b7fd889 100644 --- a/src/librustc/front/feature_gate.rs +++ b/src/librustc/front/feature_gate.rs @@ -98,7 +98,8 @@ impl Context { impl Visitor<()> for Context { fn visit_ident(&mut self, sp: Span, id: ast::Ident, _: ()) { - let s = token::ident_to_str(&id); + let string = token::get_ident(id.name); + let s = string.get(); if !s.is_ascii() { self.gate_feature("non_ascii_idents", sp, diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index edaa2208a1ff..7e866b326319 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -1142,8 +1142,13 @@ fn list_crate_deps(data: &[u8], out: &mut io::Writer) { let r = get_crate_deps(data); for dep in r.iter() { - write!(out, "{} {}-{}-{}\n", - dep.cnum, token::ident_to_str(&dep.name), dep.hash, dep.vers); + let string = token::get_ident(dep.name.name); + write!(out, + "{} {}-{}-{}\n", + dep.cnum, + string.get(), + dep.hash, + dep.vers); } write!(out, "\n"); diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 261544adfd1f..c7ba3ab01e96 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1350,11 +1350,10 @@ fn my_visit_foreign_item(ni: &ForeignItem, index: @RefCell<~[entry]>) { match items.get(ni.id) { ast_map::NodeForeignItem(_, abi, _, pt) => { + let string = token::get_ident(ni.ident.name); debug!("writing foreign item {}::{}", - ast_map::path_to_str( - *pt, - token::get_ident_interner()), - token::ident_to_str(&ni.ident)); + ast_map::path_to_str(*pt, token::get_ident_interner()), + string.get()); let mut ebml_w = unsafe { ebml_w.unsafe_clone() diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 90c9a61b18b1..c34f5c2f56b0 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -774,7 +774,8 @@ impl BorrowckCtxt { match pat.node { ast::PatIdent(_, ref path, _) => { let ident = ast_util::path_to_ident(path); - out.push_str(token::ident_to_str(&ident)); + let string = token::get_ident(ident.name); + out.push_str(string.get()); } _ => { self.tcx.sess.bug( diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index c333bc58feee..08ab8edf750c 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -360,9 +360,10 @@ impl DeadVisitor { fn warn_dead_code(&mut self, id: ast::NodeId, span: codemap::Span, ident: &ast::Ident) { + let string = token::get_ident(ident.name); self.tcx.sess.add_lint(DeadCode, id, span, format!("code is never used: `{}`", - token::ident_to_str(ident))); + string.get())); } } diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 2562c34b54b0..ae1b71f5ccad 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -530,8 +530,10 @@ impl<'a> PrivacyVisitor<'a> { ast::ItemTrait(..) => "trait", _ => return false, }; - let msg = format!("{} `{}` is private", desc, - token::ident_to_str(&item.ident)); + let string = token::get_ident(item.ident.name); + let msg = format!("{} `{}` is private", + desc, + string.get()); self.tcx.sess.span_note(span, msg); } Some(..) | None => {} @@ -588,8 +590,10 @@ impl<'a> PrivacyVisitor<'a> { if struct_vis != ast::Public && field.vis == ast::Public { break } if !is_local(field.id) || !self.private_accessible(field.id.node) { - self.tcx.sess.span_err(span, format!("field `{}` is private", - token::ident_to_str(&ident))); + let string = token::get_ident(ident.name); + self.tcx.sess.span_err(span, + format!("field `{}` is private", + string.get())) } break; } @@ -603,8 +607,11 @@ impl<'a> PrivacyVisitor<'a> { let method_id = ty::method(self.tcx, method_id).provided_source .unwrap_or(method_id); - self.ensure_public(span, method_id, None, - format!("method `{}`", token::ident_to_str(name))); + let string = token::get_ident(name.name); + self.ensure_public(span, + method_id, + None, + format!("method `{}`", string.get())); } // Checks that a path is in scope. @@ -617,10 +624,17 @@ impl<'a> PrivacyVisitor<'a> { match *self.last_private_map.get(&path_id) { resolve::AllPublic => {}, resolve::DependsOn(def) => { - let name = token::ident_to_str(&path.segments.last().unwrap() - .identifier); - self.ensure_public(span, def, Some(origdid), - format!("{} `{}`", tyname, name)); + let name = token::get_ident(path.segments + .last() + .unwrap() + .identifier + .name); + self.ensure_public(span, + def, + Some(origdid), + format!("{} `{}`", + tyname, + name.get())); } } }; diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index f391239df330..8b6cfe88f411 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -824,7 +824,8 @@ impl Repr for ty::Method { impl Repr for ast::Ident { fn repr(&self, _tcx: ctxt) -> ~str { - token::ident_to_str(self).to_owned() + let string = token::get_ident(self.name); + string.get().to_str() } }