librustc: Remove uses of token::ident_to_str()
from librustc
This commit is contained in:
parent
344040d470
commit
e534b565e6
src/librustc
@ -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,
|
||||
|
@ -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");
|
||||
|
@ -1350,11 +1350,10 @@ fn my_visit_foreign_item(ni: &ForeignItem,
|
||||
index: @RefCell<~[entry<i64>]>) {
|
||||
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()
|
||||
|
@ -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(
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user