提交 e534b565 编写于 作者: P Patrick Walton 提交者: Huon Wilson

librustc: Remove uses of `token::ident_to_str()` from librustc

上级 344040d4
......@@ -98,7 +98,8 @@ fn has_feature(&self, feature: &str) -> bool {
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 @@ pub fn append_loan_path_to_str(&self,
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 @@ fn symbol_is_live(&mut self, id: ast::NodeId,
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 @@ fn ensure_public(&self, span: Span, to_check: ast::DefId,
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 @@ fn check_field(&mut self, span: Span, id: ast::DefId, ident: ast::Ident,
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 @@ fn check_static_method(&mut self, span: Span, method_id: ast::DefId,
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 @@ fn check_path(&mut self, span: Span, path_id: ast::NodeId, path: &ast::Path) {
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 @@ fn repr(&self, tcx: ctxt) -> ~str {
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()
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册