mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
remove get_ident
and get_name
, make as_str
sound
This commit is contained in:
parent
9ca511cf63
commit
00a5e66f81
@ -61,7 +61,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
|
||||
("I", 1)];
|
||||
|
||||
let text = match args {
|
||||
[TtToken(_, token::Ident(s, _))] => token::get_ident(s).to_string(),
|
||||
[TtToken(_, token::Ident(s, _))] => s.to_string(),
|
||||
_ => {
|
||||
cx.span_err(sp, "argument should be a single identifier");
|
||||
return DummyResult::any(sp);
|
||||
@ -186,8 +186,7 @@ impl LintPass for Pass {
|
||||
}
|
||||
|
||||
fn check_item(&mut self, cx: &Context, it: &ast::Item) {
|
||||
let name = token::get_ident(it.ident);
|
||||
if name.get() == "lintme" {
|
||||
if it.ident.name == "lintme" {
|
||||
cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'");
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,7 @@ impl PathElem {
|
||||
|
||||
impl fmt::Display for PathElem {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let slot = token::get_name(self.name());
|
||||
write!(f, "{}", slot)
|
||||
write!(f, "{}", self.name())
|
||||
}
|
||||
}
|
||||
|
||||
@ -1073,18 +1072,18 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
|
||||
match ii.node {
|
||||
ConstImplItem(..) => {
|
||||
format!("assoc const {} in {}{}",
|
||||
token::get_ident(ii.ident),
|
||||
ii.ident,
|
||||
map.path_to_string(id),
|
||||
id_str)
|
||||
}
|
||||
MethodImplItem(..) => {
|
||||
format!("method {} in {}{}",
|
||||
token::get_ident(ii.ident),
|
||||
ii.ident,
|
||||
map.path_to_string(id), id_str)
|
||||
}
|
||||
TypeImplItem(_) => {
|
||||
format!("assoc type {} in {}{}",
|
||||
token::get_ident(ii.ident),
|
||||
ii.ident,
|
||||
map.path_to_string(id),
|
||||
id_str)
|
||||
}
|
||||
@ -1103,13 +1102,13 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
|
||||
|
||||
format!("{} {} in {}{}",
|
||||
kind,
|
||||
token::get_ident(ti.ident),
|
||||
ti.ident,
|
||||
map.path_to_string(id),
|
||||
id_str)
|
||||
}
|
||||
Some(NodeVariant(ref variant)) => {
|
||||
format!("variant {} in {}{}",
|
||||
token::get_ident(variant.node.name),
|
||||
variant.node.name,
|
||||
map.path_to_string(id), id_str)
|
||||
}
|
||||
Some(NodeExpr(ref expr)) => {
|
||||
|
@ -33,7 +33,6 @@ use syntax::attr::AttrMetaMethods;
|
||||
use syntax::codemap::{self, Span, mk_sp, Pos};
|
||||
use syntax::parse;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::parse::token;
|
||||
use syntax::visit;
|
||||
use log;
|
||||
|
||||
@ -181,19 +180,18 @@ impl<'a> CrateReader<'a> {
|
||||
fn extract_crate_info(&self, i: &ast::Item) -> Option<CrateInfo> {
|
||||
match i.node {
|
||||
ast::ItemExternCrate(ref path_opt) => {
|
||||
let ident = token::get_ident(i.ident);
|
||||
debug!("resolving extern crate stmt. ident: {} path_opt: {:?}",
|
||||
ident, path_opt);
|
||||
i.ident, path_opt);
|
||||
let name = match *path_opt {
|
||||
Some(name) => {
|
||||
validate_crate_name(Some(self.sess), name.as_str(),
|
||||
validate_crate_name(Some(self.sess), &name.as_str(),
|
||||
Some(i.span));
|
||||
name.as_str().to_string()
|
||||
name.to_string()
|
||||
}
|
||||
None => ident.to_string(),
|
||||
None => i.ident.to_string(),
|
||||
};
|
||||
Some(CrateInfo {
|
||||
ident: ident.to_string(),
|
||||
ident: i.ident.to_string(),
|
||||
name: name,
|
||||
id: i.id,
|
||||
should_link: should_link(i),
|
||||
|
@ -40,7 +40,6 @@ use syntax::attr;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::diagnostic::SpanHandler;
|
||||
use syntax::parse::token::special_idents;
|
||||
use syntax::parse::token;
|
||||
use syntax::print::pprust;
|
||||
use syntax::ptr::P;
|
||||
use syntax::visit::Visitor;
|
||||
@ -83,11 +82,11 @@ pub struct EncodeContext<'a, 'tcx: 'a> {
|
||||
}
|
||||
|
||||
fn encode_name(rbml_w: &mut Encoder, name: ast::Name) {
|
||||
rbml_w.wr_tagged_str(tag_paths_data_name, &token::get_name(name));
|
||||
rbml_w.wr_tagged_str(tag_paths_data_name, &name.as_str());
|
||||
}
|
||||
|
||||
fn encode_impl_type_basename(rbml_w: &mut Encoder, name: ast::Name) {
|
||||
rbml_w.wr_tagged_str(tag_item_impl_type_basename, &token::get_name(name));
|
||||
rbml_w.wr_tagged_str(tag_item_impl_type_basename, &name.as_str());
|
||||
}
|
||||
|
||||
fn encode_def_id(rbml_w: &mut Encoder, id: DefId) {
|
||||
@ -349,7 +348,7 @@ fn encode_path<PI: Iterator<Item=PathElem>>(rbml_w: &mut Encoder, path: PI) {
|
||||
ast_map::PathMod(_) => tag_path_elem_mod,
|
||||
ast_map::PathName(_) => tag_path_elem_name
|
||||
};
|
||||
rbml_w.wr_tagged_str(tag, &token::get_name(pe.name()));
|
||||
rbml_w.wr_tagged_str(tag, &pe.name().as_str());
|
||||
}
|
||||
rbml_w.end_tag();
|
||||
}
|
||||
@ -359,13 +358,13 @@ fn encode_reexported_static_method(rbml_w: &mut Encoder,
|
||||
method_def_id: DefId,
|
||||
method_name: ast::Name) {
|
||||
debug!("(encode reexported static method) {}::{}",
|
||||
exp.name, token::get_name(method_name));
|
||||
exp.name, method_name);
|
||||
rbml_w.start_tag(tag_items_data_item_reexport);
|
||||
rbml_w.wr_tagged_u64(tag_items_data_item_reexport_def_id,
|
||||
def_to_u64(method_def_id));
|
||||
rbml_w.wr_tagged_str(tag_items_data_item_reexport_name,
|
||||
&format!("{}::{}", exp.name,
|
||||
token::get_name(method_name)));
|
||||
method_name));
|
||||
rbml_w.end_tag();
|
||||
}
|
||||
|
||||
@ -499,15 +498,12 @@ fn encode_reexports(ecx: &EncodeContext,
|
||||
rbml_w.wr_tagged_u64(tag_items_data_item_reexport_def_id,
|
||||
def_to_u64(exp.def_id));
|
||||
rbml_w.wr_tagged_str(tag_items_data_item_reexport_name,
|
||||
exp.name.as_str());
|
||||
&exp.name.as_str());
|
||||
rbml_w.end_tag();
|
||||
encode_reexported_static_methods(ecx, rbml_w, path.clone(), exp);
|
||||
}
|
||||
}
|
||||
None => {
|
||||
debug!("(encoding info for module) found no reexports for {}",
|
||||
id);
|
||||
}
|
||||
},
|
||||
None => debug!("(encoding info for module) found no reexports for {}", id),
|
||||
}
|
||||
}
|
||||
|
||||
@ -539,7 +535,7 @@ fn encode_info_for_mod(ecx: &EncodeContext,
|
||||
if let ast::ItemImpl(..) = item.node {
|
||||
let (ident, did) = (item.ident, item.id);
|
||||
debug!("(encoding info for module) ... encoding impl {} ({}/{})",
|
||||
token::get_ident(ident),
|
||||
ident,
|
||||
did, ecx.tcx.map.node_to_string(did));
|
||||
|
||||
rbml_w.wr_tagged_u64(tag_mod_impl, def_to_u64(local_def(did)));
|
||||
@ -656,7 +652,7 @@ fn encode_info_for_struct(ecx: &EncodeContext,
|
||||
});
|
||||
rbml_w.start_tag(tag_items_data_item);
|
||||
debug!("encode_info_for_struct: doing {} {}",
|
||||
token::get_name(nm), id);
|
||||
nm, id);
|
||||
encode_struct_field_family(rbml_w, field.vis);
|
||||
encode_name(rbml_w, nm);
|
||||
encode_bounds_and_type_for_item(rbml_w, ecx, id);
|
||||
@ -816,7 +812,7 @@ fn encode_info_for_associated_const(ecx: &EncodeContext,
|
||||
impl_item_opt: Option<&ast::ImplItem>) {
|
||||
debug!("encode_info_for_associated_const({:?},{:?})",
|
||||
associated_const.def_id,
|
||||
token::get_name(associated_const.name));
|
||||
associated_const.name);
|
||||
|
||||
rbml_w.start_tag(tag_items_data_item);
|
||||
|
||||
@ -854,7 +850,7 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
|
||||
impl_item_opt: Option<&ast::ImplItem>) {
|
||||
|
||||
debug!("encode_info_for_method: {:?} {:?}", m.def_id,
|
||||
token::get_name(m.name));
|
||||
m.name);
|
||||
rbml_w.start_tag(tag_items_data_item);
|
||||
|
||||
encode_method_ty_fields(ecx, rbml_w, m);
|
||||
@ -899,7 +895,7 @@ fn encode_info_for_associated_type<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
|
||||
impl_item_opt: Option<&ast::ImplItem>) {
|
||||
debug!("encode_info_for_associated_type({:?},{:?})",
|
||||
associated_type.def_id,
|
||||
token::get_name(associated_type.name));
|
||||
associated_type.name);
|
||||
|
||||
rbml_w.start_tag(tag_items_data_item);
|
||||
|
||||
@ -937,7 +933,7 @@ fn encode_method_argument_names(rbml_w: &mut Encoder,
|
||||
for arg in &decl.inputs {
|
||||
let tag = tag_method_argument_name;
|
||||
if let ast::PatIdent(_, ref path1, _) = arg.pat.node {
|
||||
let name = token::get_name(path1.node.name);
|
||||
let name = path1.node.name.as_str();
|
||||
rbml_w.wr_tagged_bytes(tag, name.as_bytes());
|
||||
} else {
|
||||
rbml_w.wr_tagged_bytes(tag, &[]);
|
||||
@ -1562,7 +1558,7 @@ fn my_visit_foreign_item(ni: &ast::ForeignItem,
|
||||
index: &mut Vec<entry<i64>>) {
|
||||
debug!("writing foreign item {}::{}",
|
||||
ecx.tcx.map.path_to_string(ni.id),
|
||||
token::get_ident(ni.ident));
|
||||
ni.ident);
|
||||
|
||||
let abi = ecx.tcx.map.get_foreign_abi(ni.id);
|
||||
ecx.tcx.map.with_path(ni.id, |path| {
|
||||
@ -1748,7 +1744,7 @@ fn encode_defaulted(rbml_w: &mut Encoder, is_defaulted: bool) {
|
||||
fn encode_associated_type_names(rbml_w: &mut Encoder, names: &[ast::Name]) {
|
||||
rbml_w.start_tag(tag_associated_type_names);
|
||||
for &name in names {
|
||||
rbml_w.wr_tagged_str(tag_associated_type_name, &token::get_name(name));
|
||||
rbml_w.wr_tagged_str(tag_associated_type_name, &name.as_str());
|
||||
}
|
||||
rbml_w.end_tag();
|
||||
}
|
||||
|
@ -149,8 +149,7 @@ impl<'a> MacroLoader<'a> {
|
||||
let mut seen = HashSet::new();
|
||||
|
||||
for mut def in macros {
|
||||
let name = token::get_ident(def.ident);
|
||||
seen.insert(name.clone());
|
||||
let name = def.ident.name.as_str();
|
||||
|
||||
def.use_locally = match import.as_ref() {
|
||||
None => true,
|
||||
@ -161,18 +160,19 @@ impl<'a> MacroLoader<'a> {
|
||||
"allow_internal_unstable");
|
||||
debug!("load_macros: loaded: {:?}", def);
|
||||
self.macros.push(def);
|
||||
seen.insert(name);
|
||||
}
|
||||
|
||||
if let Some(sel) = import.as_ref() {
|
||||
for (name, span) in sel {
|
||||
if !seen.contains(name) {
|
||||
if !seen.contains(&name) {
|
||||
self.sess.span_err(*span, "imported macro not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (name, span) in &reexport {
|
||||
if !seen.contains(name) {
|
||||
if !seen.contains(&name) {
|
||||
self.sess.span_err(*span, "reexported macro not found");
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ use util::nodemap::FnvHashMap;
|
||||
use syntax::abi::Abi;
|
||||
use syntax::ast;
|
||||
use syntax::diagnostic::SpanHandler;
|
||||
use syntax::parse::token;
|
||||
|
||||
use rbml::writer::Encoder;
|
||||
|
||||
@ -136,7 +135,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
|
||||
cx.diag.handler().bug("cannot encode inference variable types");
|
||||
}
|
||||
ty::TyParam(ParamTy {space, idx, name}) => {
|
||||
mywrite!(w, "p[{}|{}|{}]", idx, space.to_uint(), token::get_name(name))
|
||||
mywrite!(w, "p[{}|{}|{}]", idx, space.to_uint(), name)
|
||||
}
|
||||
ty::TyStruct(def, substs) => {
|
||||
mywrite!(w, "a[{}|", (cx.ds)(def));
|
||||
@ -155,7 +154,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
|
||||
ty::TyProjection(ref data) => {
|
||||
mywrite!(w, "P[");
|
||||
enc_trait_ref(w, cx, data.trait_ref);
|
||||
mywrite!(w, "{}]", token::get_name(data.item_name));
|
||||
mywrite!(w, "{}]", data.item_name);
|
||||
}
|
||||
ty::TyError => {
|
||||
mywrite!(w, "e");
|
||||
@ -251,7 +250,7 @@ pub fn enc_region(w: &mut Encoder, cx: &ctxt, r: ty::Region) {
|
||||
data.param_id,
|
||||
data.space.to_uint(),
|
||||
data.index,
|
||||
token::get_name(data.name));
|
||||
data.name);
|
||||
}
|
||||
ty::ReFree(ref fr) => {
|
||||
mywrite!(w, "f[");
|
||||
@ -302,7 +301,7 @@ fn enc_bound_region(w: &mut Encoder, cx: &ctxt, br: ty::BoundRegion) {
|
||||
ty::BrNamed(d, name) => {
|
||||
mywrite!(w, "[{}|{}]",
|
||||
(cx.ds)(d),
|
||||
token::get_name(name));
|
||||
name);
|
||||
}
|
||||
ty::BrFresh(id) => {
|
||||
mywrite!(w, "f{}|", id);
|
||||
@ -410,7 +409,7 @@ pub fn enc_region_bounds<'a, 'tcx>(w: &mut Encoder,
|
||||
pub fn enc_type_param_def<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>,
|
||||
v: &ty::TypeParameterDef<'tcx>) {
|
||||
mywrite!(w, "{}:{}|{}|{}|{}|",
|
||||
token::get_name(v.name), (cx.ds)(v.def_id),
|
||||
v.name, (cx.ds)(v.def_id),
|
||||
v.space.to_uint(), v.index, (cx.ds)(v.default_def_id));
|
||||
enc_opt(w, v.default, |w, t| enc_ty(w, cx, t));
|
||||
enc_object_lifetime_default(w, cx, v.object_lifetime_default);
|
||||
@ -465,6 +464,6 @@ fn enc_projection_predicate<'a, 'tcx>(w: &mut Encoder,
|
||||
cx: &ctxt<'a, 'tcx>,
|
||||
data: &ty::ProjectionPredicate<'tcx>) {
|
||||
enc_trait_ref(w, cx, data.projection_ty.trait_ref);
|
||||
mywrite!(w, "{}|", token::get_name(data.projection_ty.item_name));
|
||||
mywrite!(w, "{}|", data.projection_ty.item_name);
|
||||
enc_ty(w, cx, data.ty);
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ use middle::ty::{self, Ty};
|
||||
use syntax::{ast, ast_util, codemap, fold};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::fold::Folder;
|
||||
use syntax::parse::token;
|
||||
use syntax::ptr::P;
|
||||
use syntax;
|
||||
|
||||
@ -156,10 +155,10 @@ pub fn decode_inlined_item<'tcx>(cdata: &cstore::crate_metadata,
|
||||
ast::IITraitItem(_, ref ti) => ti.ident,
|
||||
ast::IIImplItem(_, ref ii) => ii.ident
|
||||
};
|
||||
debug!("Fn named: {}", token::get_ident(ident));
|
||||
debug!("Fn named: {}", ident);
|
||||
debug!("< Decoded inlined fn: {}::{}",
|
||||
path_as_str.unwrap(),
|
||||
token::get_ident(ident));
|
||||
ident);
|
||||
region::resolve_inlined_item(&tcx.sess, &tcx.region_maps, ii);
|
||||
decode_side_tables(dcx, ast_doc);
|
||||
match *ii {
|
||||
|
@ -35,7 +35,6 @@ use syntax::ast_util;
|
||||
use syntax::codemap::{Span, Spanned, DUMMY_SP};
|
||||
use syntax::fold::{Folder, noop_fold_pat};
|
||||
use syntax::print::pprust::pat_to_string;
|
||||
use syntax::parse::token;
|
||||
use syntax::ptr::P;
|
||||
use syntax::visit::{self, Visitor, FnKind};
|
||||
use util::nodemap::FnvHashMap;
|
||||
@ -239,17 +238,17 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
|
||||
let def = cx.tcx.def_map.borrow().get(&p.id).map(|d| d.full_def());
|
||||
if let Some(DefLocal(_)) = def {
|
||||
if cx.tcx.enum_variants(def_id).iter().any(|variant|
|
||||
token::get_name(variant.name) == token::get_name(ident.node.name)
|
||||
variant.name == ident.node.name
|
||||
&& variant.args.is_empty()
|
||||
) {
|
||||
span_warn!(cx.tcx.sess, p.span, E0170,
|
||||
"pattern binding `{}` is named the same as one \
|
||||
of the variants of the type `{}`",
|
||||
&token::get_ident(ident.node), pat_ty);
|
||||
ident.node, pat_ty);
|
||||
fileline_help!(cx.tcx.sess, p.span,
|
||||
"if you meant to match on a variant, \
|
||||
consider making the path in the pattern qualified: `{}::{}`",
|
||||
pat_ty, &token::get_ident(ident.node));
|
||||
pat_ty, ident.node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1036,8 +1036,9 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
if let Struct(struct_id) = c {
|
||||
if let ast::ExprStruct(_, ref fields, _) = tcx.map.expect_expr(struct_id).node {
|
||||
// Check that the given field exists and evaluate it
|
||||
if let Some(f) = fields.iter().find(|f| f.ident.node.as_str()
|
||||
== field_name.node.as_str()) {
|
||||
// if the idents are compared run-pass/issue-19244 fails
|
||||
if let Some(f) = fields.iter().find(|f| f.ident.node.name
|
||||
== field_name.node.name) {
|
||||
return eval_const_expr_partial(tcx, &*f.expr, base_hint)
|
||||
} else {
|
||||
signal!(e, MissingStructField);
|
||||
|
@ -194,9 +194,7 @@ impl<'tcx> ty::ctxt<'tcx> {
|
||||
|
||||
ty::ReEmpty => ("the empty lifetime".to_owned(), None),
|
||||
|
||||
ty::ReEarlyBound(ref data) => {
|
||||
(format!("{}", token::get_name(data.name)), None)
|
||||
}
|
||||
ty::ReEarlyBound(ref data) => (data.name.to_string(), None),
|
||||
|
||||
// I believe these cases should not occur (except when debugging,
|
||||
// perhaps)
|
||||
@ -1056,7 +1054,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
|
||||
// choice of lifetime name deterministic and thus easier to test.
|
||||
let mut names = Vec::new();
|
||||
for rn in region_names {
|
||||
let lt_name = token::get_name(*rn).to_string();
|
||||
let lt_name = rn.to_string();
|
||||
names.push(lt_name);
|
||||
}
|
||||
names.sort();
|
||||
@ -1544,15 +1542,15 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
}
|
||||
infer::LateBoundRegion(_, br, infer::AssocTypeProjection(type_name)) => {
|
||||
format!(" for lifetime parameter {}in trait containing associated type `{}`",
|
||||
br_string(br), token::get_name(type_name))
|
||||
br_string(br), type_name)
|
||||
}
|
||||
infer::EarlyBoundRegion(_, name) => {
|
||||
format!(" for lifetime parameter `{}`",
|
||||
&token::get_name(name))
|
||||
name)
|
||||
}
|
||||
infer::BoundRegionInCoherence(name) => {
|
||||
format!(" for lifetime parameter `{}` in coherence check",
|
||||
&token::get_name(name))
|
||||
name)
|
||||
}
|
||||
infer::UpvarRegion(ref upvar_id, _) => {
|
||||
format!(" for capture of `{}` by closure",
|
||||
@ -1838,7 +1836,7 @@ impl LifeGiver {
|
||||
fn with_taken(taken: &[ast::LifetimeDef]) -> LifeGiver {
|
||||
let mut taken_ = HashSet::new();
|
||||
for lt in taken {
|
||||
let lt_name = token::get_name(lt.lifetime.name).to_string();
|
||||
let lt_name = lt.lifetime.name.to_string();
|
||||
taken_.insert(lt_name);
|
||||
}
|
||||
LifeGiver {
|
||||
|
@ -21,7 +21,6 @@ use syntax::abi::RustIntrinsic;
|
||||
use syntax::ast::DefId;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token;
|
||||
use syntax::visit::Visitor;
|
||||
use syntax::visit;
|
||||
|
||||
@ -61,16 +60,14 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
|
||||
if def_id.krate == ast::LOCAL_CRATE {
|
||||
match self.tcx.map.get(def_id.node) {
|
||||
NodeForeignItem(ref item) if intrinsic => {
|
||||
token::get_ident(item.ident) ==
|
||||
token::intern_and_get_ident("transmute")
|
||||
item.ident.name == "transmute"
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
} else {
|
||||
match csearch::get_item_path(self.tcx, def_id).last() {
|
||||
Some(ref last) if intrinsic => {
|
||||
token::get_name(last.name()) ==
|
||||
token::intern_and_get_ident("transmute")
|
||||
last.name() == "transmute"
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ use std::io;
|
||||
use std::rc::Rc;
|
||||
use syntax::ast::{self, NodeId, Expr};
|
||||
use syntax::codemap::{BytePos, original_sp, Span};
|
||||
use syntax::parse::token::{self, special_idents};
|
||||
use syntax::parse::token::special_idents;
|
||||
use syntax::print::pprust::{expr_to_string, block_to_string};
|
||||
use syntax::ptr::P;
|
||||
use syntax::ast_util;
|
||||
@ -332,7 +332,7 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> {
|
||||
fn variable_name(&self, var: Variable) -> String {
|
||||
match self.var_kinds[var.get()] {
|
||||
Local(LocalInfo { name, .. }) | Arg(_, name) => {
|
||||
token::get_name(name).to_string()
|
||||
name.to_string()
|
||||
},
|
||||
ImplicitRet => "<implicit-ret>".to_string(),
|
||||
CleanExit => "<clean-exit>".to_string()
|
||||
|
@ -28,7 +28,6 @@ use std::mem::replace;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token::special_idents;
|
||||
use syntax::parse::token;
|
||||
use syntax::print::pprust::lifetime_to_string;
|
||||
use syntax::visit;
|
||||
use syntax::visit::Visitor;
|
||||
@ -664,7 +663,7 @@ impl<'a> LifetimeContext<'a> {
|
||||
fn unresolved_lifetime_ref(&self, lifetime_ref: &ast::Lifetime) {
|
||||
span_err!(self.sess, lifetime_ref.span, E0261,
|
||||
"use of undeclared lifetime name `{}`",
|
||||
token::get_name(lifetime_ref.name));
|
||||
lifetime_ref.name);
|
||||
}
|
||||
|
||||
fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &Vec<ast::LifetimeDef>) {
|
||||
@ -676,7 +675,7 @@ impl<'a> LifetimeContext<'a> {
|
||||
if special_idents.iter().any(|&i| i.name == lifetime.lifetime.name) {
|
||||
span_err!(self.sess, lifetime.lifetime.span, E0262,
|
||||
"illegal lifetime parameter name: `{}`",
|
||||
token::get_name(lifetime.lifetime.name));
|
||||
lifetime.lifetime.name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -688,7 +687,7 @@ impl<'a> LifetimeContext<'a> {
|
||||
span_err!(self.sess, lifetime_j.lifetime.span, E0263,
|
||||
"lifetime name `{}` declared twice in \
|
||||
the same scope",
|
||||
token::get_name(lifetime_j.lifetime.name));
|
||||
lifetime_j.lifetime.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Checker<'a, 'tcx> {
|
||||
// When compiling with --test we don't enforce stability on the
|
||||
// compiler-generated test module, demarcated with `DUMMY_SP` plus the
|
||||
// name `__test`
|
||||
if item.span == DUMMY_SP && item.ident.as_str() == "__test" { return }
|
||||
if item.span == DUMMY_SP && item.ident.name == "__test" { return }
|
||||
|
||||
check_item(self.tcx, item, true,
|
||||
&mut |id, sp, stab| self.check(id, sp, stab));
|
||||
|
@ -5292,19 +5292,13 @@ impl<'tcx> ctxt<'tcx> {
|
||||
match self.map.find(id) {
|
||||
Some(ast_map::NodeLocal(pat)) => {
|
||||
match pat.node {
|
||||
ast::PatIdent(_, ref path1, _) => {
|
||||
token::get_ident(path1.node)
|
||||
}
|
||||
ast::PatIdent(_, ref path1, _) => path1.node.name.as_str(),
|
||||
_ => {
|
||||
self.sess.bug(&format!("Variable id {} maps to {:?}, not local",
|
||||
id, pat));
|
||||
}
|
||||
self.sess.bug(&format!("Variable id {} maps to {:?}, not local", id, pat));
|
||||
},
|
||||
}
|
||||
}
|
||||
r => {
|
||||
self.sess.bug(&format!("Variable id {} maps to {:?}, not local",
|
||||
id, r));
|
||||
}
|
||||
},
|
||||
r => self.sess.bug(&format!("Variable id {} maps to {:?}, not local", id, r)),
|
||||
}
|
||||
}
|
||||
|
||||
@ -5396,9 +5390,9 @@ impl<'tcx> ctxt<'tcx> {
|
||||
for f in fields { if f.name == name { return i; } i += 1; }
|
||||
self.sess.bug(&format!(
|
||||
"no field named `{}` found in the list of fields `{:?}`",
|
||||
token::get_name(name),
|
||||
name,
|
||||
fields.iter()
|
||||
.map(|f| token::get_name(f.name).to_string())
|
||||
.map(|f| f.name.to_string())
|
||||
.collect::<Vec<String>>()));
|
||||
}
|
||||
|
||||
@ -5815,13 +5809,13 @@ impl<'tcx> ctxt<'tcx> {
|
||||
"expected {} integer constant",
|
||||
sign_desc);
|
||||
current_disr_val = attempt_fresh_value();
|
||||
}
|
||||
},
|
||||
Err(ref err) => {
|
||||
span_err!(self.sess, err.span, E0080,
|
||||
"constant evaluation error: {}",
|
||||
err.description());
|
||||
current_disr_val = attempt_fresh_value();
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
None => {
|
||||
@ -5830,14 +5824,14 @@ impl<'tcx> ctxt<'tcx> {
|
||||
if let Some(v) = repr_type.disr_incr(prev_disr_val) {
|
||||
v
|
||||
} else {
|
||||
self.report_discrim_overflow(v.span, v.node.name.as_str(),
|
||||
self.report_discrim_overflow(v.span, &v.node.name.name.as_str(),
|
||||
repr_type, prev_disr_val);
|
||||
attempt_fresh_value()
|
||||
}
|
||||
}
|
||||
None => ty::INITIAL_DISCRIMINANT_VALUE
|
||||
None => ty::INITIAL_DISCRIMINANT_VALUE,
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
let variant_info = Rc::new(VariantInfo::from_ast_variant(self, &**v, current_disr_val));
|
||||
@ -6472,7 +6466,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||
byte!(20);
|
||||
hash!(p.space);
|
||||
hash!(p.idx);
|
||||
hash!(token::get_name(p.name));
|
||||
hash!(p.name.as_str());
|
||||
}
|
||||
TyInfer(_) => unreachable!(),
|
||||
TyError => byte!(21),
|
||||
@ -6483,7 +6477,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||
TyProjection(ref data) => {
|
||||
byte!(23);
|
||||
did(state, data.trait_ref.def_id);
|
||||
hash!(token::get_name(data.item_name));
|
||||
hash!(data.item_name.as_str());
|
||||
}
|
||||
}
|
||||
true
|
||||
|
@ -265,20 +265,20 @@ mod svh_visitor {
|
||||
ExprCast(..) => SawExprCast,
|
||||
ExprIf(..) => SawExprIf,
|
||||
ExprWhile(..) => SawExprWhile,
|
||||
ExprLoop(_, id) => SawExprLoop(id.map(content)),
|
||||
ExprLoop(_, id) => SawExprLoop(id.map(|id| id.name.as_str())),
|
||||
ExprMatch(..) => SawExprMatch,
|
||||
ExprClosure(..) => SawExprClosure,
|
||||
ExprBlock(..) => SawExprBlock,
|
||||
ExprAssign(..) => SawExprAssign,
|
||||
ExprAssignOp(op, _, _) => SawExprAssignOp(op.node),
|
||||
ExprField(_, id) => SawExprField(content(id.node)),
|
||||
ExprField(_, id) => SawExprField(id.node.name.as_str()),
|
||||
ExprTupField(_, id) => SawExprTupField(id.node),
|
||||
ExprIndex(..) => SawExprIndex,
|
||||
ExprRange(..) => SawExprRange,
|
||||
ExprPath(ref qself, _) => SawExprPath(qself.as_ref().map(|q| q.position)),
|
||||
ExprAddrOf(m, _) => SawExprAddrOf(m),
|
||||
ExprBreak(id) => SawExprBreak(id.map(content)),
|
||||
ExprAgain(id) => SawExprAgain(id.map(content)),
|
||||
ExprBreak(id) => SawExprBreak(id.map(|id| id.name.as_str())),
|
||||
ExprAgain(id) => SawExprAgain(id.map(|id| id.name.as_str())),
|
||||
ExprRet(..) => SawExprRet,
|
||||
ExprInlineAsm(ref asm) => SawExprInlineAsm(asm),
|
||||
ExprStruct(..) => SawExprStruct,
|
||||
@ -310,16 +310,6 @@ mod svh_visitor {
|
||||
}
|
||||
}
|
||||
|
||||
// Ad-hoc overloading between Ident and Name to their intern table lookups.
|
||||
trait InternKey { fn get_content(self) -> token::InternedString; }
|
||||
impl InternKey for Ident {
|
||||
fn get_content(self) -> token::InternedString { token::get_ident(self) }
|
||||
}
|
||||
impl InternKey for Name {
|
||||
fn get_content(self) -> token::InternedString { token::get_name(self) }
|
||||
}
|
||||
fn content<K:InternKey>(k: K) -> token::InternedString { k.get_content() }
|
||||
|
||||
impl<'a, 'v> Visitor<'v> for StrictVersionHashVisitor<'a> {
|
||||
|
||||
fn visit_mac(&mut self, mac: &Mac) {
|
||||
@ -355,7 +345,7 @@ mod svh_visitor {
|
||||
&MacInvocTT(ref path, ref _tts, ref _stx_ctxt) => {
|
||||
let s = &path.segments;
|
||||
assert_eq!(s.len(), 1);
|
||||
content(s[0].identifier)
|
||||
s[0].identifier.name.as_str()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -363,7 +353,7 @@ mod svh_visitor {
|
||||
|
||||
fn visit_struct_def(&mut self, s: &StructDef, ident: Ident,
|
||||
g: &Generics, _: NodeId) {
|
||||
SawStructDef(content(ident)).hash(self.st);
|
||||
SawStructDef(ident.name.as_str()).hash(self.st);
|
||||
visit::walk_generics(self, g);
|
||||
visit::walk_struct_def(self, s)
|
||||
}
|
||||
@ -401,15 +391,15 @@ mod svh_visitor {
|
||||
// pattern, please move that method up above this comment.)
|
||||
|
||||
fn visit_ident(&mut self, _: Span, ident: Ident) {
|
||||
SawIdent(content(ident)).hash(self.st);
|
||||
SawIdent(ident.name.as_str()).hash(self.st);
|
||||
}
|
||||
|
||||
fn visit_lifetime_ref(&mut self, l: &Lifetime) {
|
||||
SawLifetimeRef(content(l.name)).hash(self.st);
|
||||
SawLifetimeRef(l.name.as_str()).hash(self.st);
|
||||
}
|
||||
|
||||
fn visit_lifetime_def(&mut self, l: &LifetimeDef) {
|
||||
SawLifetimeDef(content(l.lifetime.name)).hash(self.st);
|
||||
SawLifetimeDef(l.lifetime.name.as_str()).hash(self.st);
|
||||
}
|
||||
|
||||
// We do recursively walk the bodies of functions/methods
|
||||
|
@ -39,7 +39,6 @@ use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use syntax::ast_util;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token;
|
||||
use syntax::visit;
|
||||
use syntax::visit::{Visitor, FnKind};
|
||||
use syntax::ast::{FnDecl, Block, NodeId};
|
||||
@ -1065,7 +1064,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
match fname {
|
||||
mc::NamedField(fname) => {
|
||||
out.push('.');
|
||||
out.push_str(&token::get_name(fname));
|
||||
out.push_str(&fname.as_str());
|
||||
}
|
||||
mc::PositionalField(idx) => {
|
||||
out.push('.');
|
||||
|
@ -53,7 +53,6 @@ use syntax::ast_util::{self, is_shift_binop, local_def};
|
||||
use syntax::attr::{self, AttrMetaMethods};
|
||||
use syntax::codemap::{self, Span};
|
||||
use syntax::feature_gate::{KNOWN_ATTRIBUTES, AttributeType};
|
||||
use syntax::parse::token;
|
||||
use syntax::ast::{TyIs, TyUs, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
|
||||
use syntax::ptr::P;
|
||||
use syntax::visit::{self, Visitor};
|
||||
@ -1043,7 +1042,7 @@ pub struct NonCamelCaseTypes;
|
||||
impl NonCamelCaseTypes {
|
||||
fn check_case(&self, cx: &Context, sort: &str, ident: ast::Ident, span: Span) {
|
||||
fn is_camel_case(ident: ast::Ident) -> bool {
|
||||
let ident = token::get_ident(ident);
|
||||
let ident = ident.name.as_str();
|
||||
if ident.is_empty() {
|
||||
return true;
|
||||
}
|
||||
@ -1064,7 +1063,7 @@ impl NonCamelCaseTypes {
|
||||
)).collect::<Vec<_>>().concat()
|
||||
}
|
||||
|
||||
let s = token::get_ident(ident);
|
||||
let s = ident.name.as_str();
|
||||
|
||||
if !is_camel_case(ident) {
|
||||
let c = to_camel_case(&s);
|
||||
@ -1245,15 +1244,15 @@ impl LintPass for NonSnakeCase {
|
||||
match fk {
|
||||
visit::FkMethod(ident, _, _) => match method_context(cx, id, span) {
|
||||
MethodContext::PlainImpl => {
|
||||
self.check_snake_case(cx, "method", &token::get_ident(ident), Some(span))
|
||||
self.check_snake_case(cx, "method", &ident.name.as_str(), Some(span))
|
||||
},
|
||||
MethodContext::TraitDefaultImpl => {
|
||||
self.check_snake_case(cx, "trait method", &token::get_ident(ident), Some(span))
|
||||
self.check_snake_case(cx, "trait method", &ident.name.as_str(), Some(span))
|
||||
},
|
||||
_ => (),
|
||||
},
|
||||
visit::FkItemFn(ident, _, _, _, _, _) => {
|
||||
self.check_snake_case(cx, "function", &token::get_ident(ident), Some(span))
|
||||
self.check_snake_case(cx, "function", &ident.name.as_str(), Some(span))
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
@ -1261,19 +1260,19 @@ impl LintPass for NonSnakeCase {
|
||||
|
||||
fn check_item(&mut self, cx: &Context, it: &ast::Item) {
|
||||
if let ast::ItemMod(_) = it.node {
|
||||
self.check_snake_case(cx, "module", &token::get_ident(it.ident), Some(it.span));
|
||||
self.check_snake_case(cx, "module", &it.ident.name.as_str(), Some(it.span));
|
||||
}
|
||||
}
|
||||
|
||||
fn check_trait_item(&mut self, cx: &Context, trait_item: &ast::TraitItem) {
|
||||
if let ast::MethodTraitItem(_, None) = trait_item.node {
|
||||
self.check_snake_case(cx, "trait method", &token::get_ident(trait_item.ident),
|
||||
self.check_snake_case(cx, "trait method", &trait_item.ident.name.as_str(),
|
||||
Some(trait_item.span));
|
||||
}
|
||||
}
|
||||
|
||||
fn check_lifetime_def(&mut self, cx: &Context, t: &ast::LifetimeDef) {
|
||||
self.check_snake_case(cx, "lifetime", &token::get_ident(t.lifetime.name.ident()),
|
||||
self.check_snake_case(cx, "lifetime", &t.lifetime.name.as_str(),
|
||||
Some(t.lifetime.span));
|
||||
}
|
||||
|
||||
@ -1281,7 +1280,7 @@ impl LintPass for NonSnakeCase {
|
||||
if let &ast::PatIdent(_, ref path1, _) = &p.node {
|
||||
let def = cx.tcx.def_map.borrow().get(&p.id).map(|d| d.full_def());
|
||||
if let Some(def::DefLocal(_)) = def {
|
||||
self.check_snake_case(cx, "variable", &token::get_ident(path1.node), Some(p.span));
|
||||
self.check_snake_case(cx, "variable", &path1.node.name.as_str(), Some(p.span));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1290,7 +1289,7 @@ impl LintPass for NonSnakeCase {
|
||||
_: ast::Ident, _: &ast::Generics, _: ast::NodeId) {
|
||||
for sf in &s.fields {
|
||||
if let ast::StructField_ { kind: ast::NamedField(ident, _), .. } = sf.node {
|
||||
self.check_snake_case(cx, "structure field", &token::get_ident(ident),
|
||||
self.check_snake_case(cx, "structure field", &ident.name.as_str(),
|
||||
Some(sf.span));
|
||||
}
|
||||
}
|
||||
@ -1308,7 +1307,7 @@ pub struct NonUpperCaseGlobals;
|
||||
|
||||
impl NonUpperCaseGlobals {
|
||||
fn check_upper_case(cx: &Context, sort: &str, ident: ast::Ident, span: Span) {
|
||||
let s = token::get_ident(ident);
|
||||
let s = ident.name.as_str();
|
||||
|
||||
if s.chars().any(|c| c.is_lowercase()) {
|
||||
let uc = NonSnakeCase::to_snake_case(&s).to_uppercase();
|
||||
@ -1489,7 +1488,7 @@ impl LintPass for UnusedImportBraces {
|
||||
if items.len() == 1 {
|
||||
if let ast::PathListIdent {ref name, ..} = items[0].node {
|
||||
let m = format!("braces around {} is unnecessary",
|
||||
&token::get_ident(*name));
|
||||
name);
|
||||
cx.span_lint(UNUSED_IMPORT_BRACES, item.span,
|
||||
&m[..]);
|
||||
}
|
||||
@ -1525,10 +1524,12 @@ impl LintPass for NonShorthandFieldPatterns {
|
||||
});
|
||||
for fieldpat in field_pats {
|
||||
if let ast::PatIdent(_, ident, None) = fieldpat.node.pat.node {
|
||||
if ident.node.as_str() == fieldpat.node.ident.as_str() {
|
||||
if ident.node.name == fieldpat.node.ident.name {
|
||||
// FIXME: should this comparison really be done on the name?
|
||||
// doing it on the ident will fail during compilation of libcore
|
||||
cx.span_lint(NON_SHORTHAND_FIELD_PATTERNS, fieldpat.span,
|
||||
&format!("the `{}:` in this pattern is redundant and can \
|
||||
be removed", ident.node.as_str()))
|
||||
be removed", ident.node))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1641,7 +1642,7 @@ impl UnusedMut {
|
||||
pat_util::pat_bindings(&cx.tcx.def_map, &**p, |mode, id, _, path1| {
|
||||
let ident = path1.node;
|
||||
if let ast::BindByValue(ast::MutMutable) = mode {
|
||||
if !token::get_ident(ident).starts_with("_") {
|
||||
if !ident.name.as_str().starts_with("_") {
|
||||
match mutables.entry(ident.name.usize()) {
|
||||
Vacant(entry) => { entry.insert(vec![id]); },
|
||||
Occupied(mut entry) => { entry.get_mut().push(id); },
|
||||
|
@ -46,7 +46,6 @@ use rustc::util::nodemap::{NodeMap, NodeSet};
|
||||
use syntax::ast;
|
||||
use syntax::ast_util::{is_local, local_def};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token;
|
||||
use syntax::visit::{self, Visitor};
|
||||
|
||||
type Context<'a, 'tcx> = (&'a ty::MethodMap<'tcx>, &'a def::ExportMap);
|
||||
@ -682,8 +681,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
||||
ast::ItemEnum(..) => "enum",
|
||||
_ => return Some((err_span, err_msg, None))
|
||||
};
|
||||
let msg = format!("{} `{}` is private", desc,
|
||||
token::get_ident(item.ident));
|
||||
let msg = format!("{} `{}` is private", desc, item.ident);
|
||||
Some((err_span, err_msg, Some((span, msg))))
|
||||
}
|
||||
|
||||
@ -715,7 +713,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
||||
};
|
||||
let msg = match name {
|
||||
NamedField(name) => format!("field `{}` of {} is private",
|
||||
token::get_name(name), struct_desc),
|
||||
name, struct_desc),
|
||||
UnnamedField(idx) => format!("field #{} of {} is private",
|
||||
idx + 1, struct_desc),
|
||||
};
|
||||
@ -740,12 +738,11 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
||||
}
|
||||
};
|
||||
|
||||
let string = token::get_name(name);
|
||||
self.report_error(self.ensure_public(span,
|
||||
method_id,
|
||||
None,
|
||||
&format!("method `{}`",
|
||||
string)));
|
||||
name)));
|
||||
}
|
||||
|
||||
// Checks that a path is in scope.
|
||||
@ -755,12 +752,11 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
||||
let ck = |tyname: &str| {
|
||||
let ck_public = |def: ast::DefId| {
|
||||
debug!("privacy - ck_public {:?}", def);
|
||||
let name = token::get_name(last);
|
||||
let origdid = path_res.def_id();
|
||||
self.ensure_public(span,
|
||||
def,
|
||||
Some(origdid),
|
||||
&format!("{} `{}`", tyname, name))
|
||||
&format!("{} `{}`", tyname, last))
|
||||
};
|
||||
|
||||
match path_res.last_private {
|
||||
|
@ -52,7 +52,7 @@ use syntax::ast::Visibility;
|
||||
use syntax::ast;
|
||||
use syntax::ast_util::local_def;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::parse::token::{self, special_idents};
|
||||
use syntax::parse::token::special_idents;
|
||||
use syntax::codemap::{Span, DUMMY_SP};
|
||||
use syntax::visit::{self, Visitor};
|
||||
|
||||
@ -222,7 +222,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||
self.session.span_note(sp,
|
||||
&format!("first definition of {} `{}` here",
|
||||
namespace_error_to_string(duplicate_type),
|
||||
token::get_name(name)));
|
||||
name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -294,7 +294,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||
|
||||
// Build up the import directives.
|
||||
let shadowable = item.attrs.iter().any(|attr| {
|
||||
attr.name() == token::get_name(special_idents::prelude_import.name)
|
||||
attr.name() == special_idents::prelude_import.name.as_str()
|
||||
});
|
||||
let shadowable = if shadowable {
|
||||
Shadowable::Always
|
||||
@ -306,12 +306,10 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||
ViewPathSimple(binding, ref full_path) => {
|
||||
let source_name =
|
||||
full_path.segments.last().unwrap().identifier.name;
|
||||
if &token::get_name(source_name)[..] == "mod" ||
|
||||
&token::get_name(source_name)[..] == "self" {
|
||||
if source_name.as_str() == "mod" || source_name.as_str() == "self" {
|
||||
resolve_error(self,
|
||||
view_path.span,
|
||||
ResolutionError::SelfImportsOnlyAllowedWithin
|
||||
);
|
||||
view_path.span,
|
||||
ResolutionError::SelfImportsOnlyAllowedWithin);
|
||||
}
|
||||
|
||||
let subclass = SingleImport(binding.name,
|
||||
@ -763,7 +761,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||
|
||||
debug!("(building reduced graph for external crate) ... \
|
||||
adding trait item '{}'",
|
||||
token::get_name(trait_item_name));
|
||||
trait_item_name);
|
||||
|
||||
self.trait_item_map.insert((trait_item_name, def_id),
|
||||
trait_item_def.def_id());
|
||||
@ -849,7 +847,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||
self.handle_external_def(def,
|
||||
def_visibility,
|
||||
&*child_name_bindings,
|
||||
&token::get_name(name),
|
||||
&name.as_str(),
|
||||
name,
|
||||
root);
|
||||
}
|
||||
@ -883,7 +881,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||
def_id,
|
||||
|def_like, child_name, visibility| {
|
||||
debug!("(populating external module) ... found ident: {}",
|
||||
token::get_name(child_name));
|
||||
child_name);
|
||||
self.build_reduced_graph_for_external_crate_def(module,
|
||||
def_like,
|
||||
child_name,
|
||||
@ -937,7 +935,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||
SingleImport(target, _) => {
|
||||
debug!("(building import directive) building import directive: {}::{}",
|
||||
names_to_string(&module_.imports.borrow().last().unwrap().module_path),
|
||||
token::get_name(target));
|
||||
target);
|
||||
|
||||
let mut import_resolutions = module_.import_resolutions.borrow_mut();
|
||||
match import_resolutions.get_mut(&target) {
|
||||
|
@ -1275,7 +1275,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
name_search_type,
|
||||
false) {
|
||||
Failed(None) => {
|
||||
let segment_name = token::get_name(name);
|
||||
let segment_name = name.as_str();
|
||||
let module_name = module_to_string(&*search_module);
|
||||
let mut span = span;
|
||||
let msg = if "???" == &module_name[..] {
|
||||
@ -1688,27 +1688,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
-> ResolveResult<ModulePrefixResult> {
|
||||
// Start at the current module if we see `self` or `super`, or at the
|
||||
// top of the crate otherwise.
|
||||
let mut containing_module;
|
||||
let mut i;
|
||||
let first_module_path_string = token::get_name(module_path[0]);
|
||||
if "self" == &first_module_path_string[..] {
|
||||
containing_module =
|
||||
self.get_nearest_normal_module_parent_or_self(module_);
|
||||
i = 1;
|
||||
} else if "super" == &first_module_path_string[..] {
|
||||
containing_module =
|
||||
self.get_nearest_normal_module_parent_or_self(module_);
|
||||
i = 0; // We'll handle `super` below.
|
||||
} else {
|
||||
return Success(NoPrefixFound);
|
||||
}
|
||||
let mut i = match &*module_path[0].as_str() {
|
||||
"self" => 1,
|
||||
"super" => 0,
|
||||
_ => return Success(NoPrefixFound),
|
||||
};
|
||||
let mut containing_module = self.get_nearest_normal_module_parent_or_self(module_);
|
||||
|
||||
// Now loop through all the `super`s we find.
|
||||
while i < module_path.len() {
|
||||
let string = token::get_name(module_path[i]);
|
||||
if "super" != &string[..] {
|
||||
break
|
||||
}
|
||||
while i < module_path.len() && "super" == module_path[i].as_str() {
|
||||
debug!("(resolving module prefix) resolving `super` at {}",
|
||||
module_to_string(&*containing_module));
|
||||
match self.get_nearest_normal_module_parent(containing_module) {
|
||||
@ -2761,7 +2749,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
self,
|
||||
pattern.span,
|
||||
ResolutionError::IdentifierBoundMoreThanOnceInParameterList(
|
||||
&*token::get_ident(ident))
|
||||
&ident.name.as_str())
|
||||
);
|
||||
} else if bindings_list.get(&renamed) ==
|
||||
Some(&pat_id) {
|
||||
@ -2771,7 +2759,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
self,
|
||||
pattern.span,
|
||||
ResolutionError::IdentifierBoundMoreThanOnceInSamePattern(
|
||||
&*token::get_ident(ident))
|
||||
&ident.name.as_str())
|
||||
);
|
||||
}
|
||||
// Else, not bound in the same pattern: do
|
||||
@ -2817,9 +2805,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
self,
|
||||
path.span,
|
||||
ResolutionError::NotAnEnumVariantStructOrConst(
|
||||
&*token::get_ident(
|
||||
path.segments.last().unwrap().identifier)
|
||||
)
|
||||
&path.segments
|
||||
.last()
|
||||
.unwrap()
|
||||
.identifier
|
||||
.name
|
||||
.as_str())
|
||||
);
|
||||
} else {
|
||||
let const_name = path.segments.last().unwrap()
|
||||
@ -2835,7 +2826,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
self,
|
||||
path.span,
|
||||
ResolutionError::UnresolvedEnumVariantStructOrConst(
|
||||
&*token::get_ident(path.segments.last().unwrap().identifier))
|
||||
&path.segments.last().unwrap().identifier.name.as_str())
|
||||
);
|
||||
}
|
||||
visit::walk_path(self, path);
|
||||
@ -2872,8 +2863,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
self,
|
||||
path.span,
|
||||
ResolutionError::NotAnAssociatedConst(
|
||||
&*token::get_ident(
|
||||
path.segments.last().unwrap().identifier)
|
||||
&path.segments.last().unwrap().identifier.name.as_str()
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -2883,7 +2873,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
self,
|
||||
path.span,
|
||||
ResolutionError::UnresolvedAssociatedConst(
|
||||
&*token::get_ident(path.segments.last().unwrap().identifier)
|
||||
&path.segments.last().unwrap().identifier.name.as_str()
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -3304,7 +3294,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
match search_result {
|
||||
Some(DlDef(def)) => {
|
||||
debug!("(resolving path in local ribs) resolved `{}` to local: {:?}",
|
||||
token::get_ident(ident),
|
||||
ident,
|
||||
def);
|
||||
Some(def)
|
||||
}
|
||||
@ -3492,7 +3482,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
|
||||
for rib in self.value_ribs.iter().rev() {
|
||||
for (&k, _) in &rib.bindings {
|
||||
maybes.push(token::get_name(k));
|
||||
maybes.push(k.as_str());
|
||||
values.push(usize::MAX);
|
||||
}
|
||||
}
|
||||
@ -3624,8 +3614,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
false // Stop advancing
|
||||
});
|
||||
|
||||
if method_scope &&
|
||||
&token::get_name(special_names::self_)[..] == path_name {
|
||||
if method_scope && special_names::self_ == path_name {
|
||||
resolve_error(
|
||||
self,
|
||||
expr.span,
|
||||
@ -3706,7 +3695,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
None => {
|
||||
resolve_error(self,
|
||||
expr.span,
|
||||
ResolutionError::UndeclaredLabel(&*token::get_ident(label)))
|
||||
ResolutionError::UndeclaredLabel(&label.name.as_str()))
|
||||
}
|
||||
Some(DlDef(def @ DefLabel(_))) => {
|
||||
// Since this def is a label, it is never read.
|
||||
@ -3912,7 +3901,7 @@ fn names_to_string(names: &[Name]) -> String {
|
||||
} else {
|
||||
result.push_str("::")
|
||||
}
|
||||
result.push_str(&token::get_name(*name));
|
||||
result.push_str(&name.as_str());
|
||||
};
|
||||
result
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ use module_to_string;
|
||||
|
||||
use rustc::middle::def::Export;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::rc::Rc;
|
||||
@ -143,7 +142,7 @@ impl<'a, 'b, 'tcx> ExportRecorder<'a, 'b, 'tcx> {
|
||||
match import_resolution.target_for_namespace(ns) {
|
||||
Some(target) => {
|
||||
debug!("(computing exports) maybe export '{}'",
|
||||
token::get_name(*name));
|
||||
name);
|
||||
self.add_exports_of_namebindings(exports,
|
||||
*name,
|
||||
&*target.bindings,
|
||||
|
@ -31,7 +31,6 @@ use rustc::middle::privacy::*;
|
||||
|
||||
use syntax::ast::{DefId, NodeId, Name};
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::parse::token;
|
||||
use syntax::codemap::Span;
|
||||
|
||||
use std::mem::replace;
|
||||
@ -435,10 +434,10 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
|
||||
(*child_name_bindings).clone());
|
||||
if directive.is_public && !child_name_bindings.is_public(ValueNS) {
|
||||
let msg = format!("`{}` is private, and cannot be reexported",
|
||||
token::get_name(source));
|
||||
source);
|
||||
let note_msg =
|
||||
format!("Consider marking `{}` as `pub` in the imported module",
|
||||
token::get_name(source));
|
||||
source);
|
||||
span_err!(self.resolver.session, directive.span, E0364, "{}", &msg);
|
||||
self.resolver.session.span_note(directive.span, ¬e_msg);
|
||||
pub_err = true;
|
||||
@ -450,9 +449,9 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
|
||||
(*child_name_bindings).clone());
|
||||
if !pub_err && directive.is_public && !child_name_bindings.is_public(TypeNS) {
|
||||
let msg = format!("`{}` is private, and cannot be reexported",
|
||||
token::get_name(source));
|
||||
source);
|
||||
let note_msg = format!("Consider declaring module `{}` as a `pub mod`",
|
||||
token::get_name(source));
|
||||
source);
|
||||
span_err!(self.resolver.session, directive.span, E0365, "{}", &msg);
|
||||
self.resolver.session.span_note(directive.span, ¬e_msg);
|
||||
}
|
||||
@ -1041,9 +1040,7 @@ fn import_path_to_string(names: &[Name],
|
||||
|
||||
fn import_directive_subclass_to_string(subclass: ImportDirectiveSubclass) -> String {
|
||||
match subclass {
|
||||
SingleImport(_, source) => {
|
||||
token::get_name(source).to_string()
|
||||
}
|
||||
SingleImport(_, source) => source.to_string(),
|
||||
GlobImport => "*".to_string()
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ pub fn mangle<PI: Iterator<Item=PathElem>>(path: PI,
|
||||
|
||||
// First, connect each component with <len, name> pairs.
|
||||
for e in path {
|
||||
push(&mut n, &token::get_name(e.name()))
|
||||
push(&mut n, &e.name().as_str())
|
||||
}
|
||||
|
||||
match hash {
|
||||
|
@ -40,7 +40,7 @@ use std::path::Path;
|
||||
|
||||
use syntax::ast::{self, NodeId, DefId};
|
||||
use syntax::codemap::*;
|
||||
use syntax::parse::token::{self, get_ident, keywords};
|
||||
use syntax::parse::token::{self, keywords};
|
||||
use syntax::owned_slice::OwnedSlice;
|
||||
use syntax::visit::{self, Visitor};
|
||||
use syntax::print::pprust::{path_to_string, ty_to_string};
|
||||
@ -302,7 +302,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
debug!("process_method: {}:{}", id, token::get_name(name));
|
||||
debug!("process_method: {}:{}", id, name);
|
||||
|
||||
let method_data = self.save_ctxt.get_method_data(id, name, span);
|
||||
|
||||
@ -459,7 +459,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
|
||||
self.fmt.static_str(span,
|
||||
sub_span,
|
||||
id,
|
||||
&get_ident((*ident).clone()),
|
||||
&ident.name.as_str(),
|
||||
&qualname,
|
||||
&self.span.snippet(expr.span),
|
||||
&ty_to_string(&*typ),
|
||||
@ -513,7 +513,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
|
||||
&enum_data.value);
|
||||
|
||||
for variant in &enum_definition.variants {
|
||||
let name = &get_ident(variant.node.name);
|
||||
let name = &variant.node.name.name.as_str();
|
||||
let mut qualname = enum_data.qualname.clone();
|
||||
qualname.push_str("::");
|
||||
qualname.push_str(name);
|
||||
@ -877,7 +877,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
||||
sub_span,
|
||||
item.id,
|
||||
mod_id,
|
||||
&get_ident(ident),
|
||||
&ident.name.as_str(),
|
||||
self.cur_scope);
|
||||
self.write_sub_paths_truncated(path, true);
|
||||
}
|
||||
@ -891,7 +891,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
||||
if !name_string.is_empty() {
|
||||
name_string.push_str(", ");
|
||||
}
|
||||
name_string.push_str(n.as_str());
|
||||
name_string.push_str(&n.as_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -931,11 +931,9 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
||||
}
|
||||
}
|
||||
ast::ItemExternCrate(ref s) => {
|
||||
let name = get_ident(item.ident);
|
||||
let name = &name;
|
||||
let location = match *s {
|
||||
Some(s) => s.to_string(),
|
||||
None => name.to_string(),
|
||||
None => item.ident.to_string(),
|
||||
};
|
||||
let alias_span = self.span.span_for_last_ident(item.span);
|
||||
let cnum = match self.sess.cstore.find_extern_mod_stmt_cnum(item.id) {
|
||||
@ -946,7 +944,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
||||
alias_span,
|
||||
item.id,
|
||||
cnum,
|
||||
name,
|
||||
&item.ident.name.as_str(),
|
||||
&location,
|
||||
self.cur_scope);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ use syntax::{attr};
|
||||
use syntax::ast::{self, NodeId, DefId};
|
||||
use syntax::ast_util;
|
||||
use syntax::codemap::*;
|
||||
use syntax::parse::token::{self, get_ident, keywords};
|
||||
use syntax::parse::token::{self, keywords};
|
||||
use syntax::visit::{self, Visitor};
|
||||
use syntax::print::pprust::ty_to_string;
|
||||
|
||||
@ -217,7 +217,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
|
||||
Data::VariableData(VariableData {
|
||||
id: item.id,
|
||||
name: get_ident(item.ident).to_string(),
|
||||
name: item.ident.to_string(),
|
||||
qualname: qualname,
|
||||
span: sub_span.unwrap(),
|
||||
scope: self.enclosing_scope(item.id),
|
||||
@ -231,7 +231,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
|
||||
Data::VariableData(VariableData {
|
||||
id: item.id,
|
||||
name: get_ident(item.ident).to_string(),
|
||||
name: item.ident.to_string(),
|
||||
qualname: qualname,
|
||||
span: sub_span.unwrap(),
|
||||
scope: self.enclosing_scope(item.id),
|
||||
@ -249,7 +249,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
|
||||
Data::ModData(ModData {
|
||||
id: item.id,
|
||||
name: get_ident(item.ident).to_string(),
|
||||
name: item.ident.to_string(),
|
||||
qualname: qualname,
|
||||
span: sub_span.unwrap(),
|
||||
scope: self.enclosing_scope(item.id),
|
||||
@ -313,16 +313,15 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
pub fn get_field_data(&self, field: &ast::StructField, scope: NodeId) -> Option<VariableData> {
|
||||
match field.node.kind {
|
||||
ast::NamedField(ident, _) => {
|
||||
let name = get_ident(ident);
|
||||
let qualname = format!("::{}::{}",
|
||||
self.tcx.map.path_to_string(scope),
|
||||
name);
|
||||
ident);
|
||||
let typ = self.tcx.node_types().get(&field.node.id).unwrap()
|
||||
.to_string();
|
||||
let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon);
|
||||
Some(VariableData {
|
||||
id: field.node.id,
|
||||
name: get_ident(ident).to_string(),
|
||||
name: ident.to_string(),
|
||||
qualname: qualname,
|
||||
span: sub_span.unwrap(),
|
||||
scope: scope,
|
||||
@ -394,7 +393,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
},
|
||||
};
|
||||
|
||||
let qualname = format!("{}::{}", qualname, &token::get_name(name));
|
||||
let qualname = format!("{}::{}", qualname, name);
|
||||
|
||||
let decl_id = self.tcx.trait_item_of_item(ast_util::local_def(id))
|
||||
.and_then(|new_id| {
|
||||
@ -410,7 +409,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
|
||||
FunctionData {
|
||||
id: id,
|
||||
name: token::get_name(name).to_string(),
|
||||
name: name.to_string(),
|
||||
qualname: qualname,
|
||||
declaration: decl_id,
|
||||
span: sub_span.unwrap(),
|
||||
@ -444,7 +443,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
if f.name == ident.node.name {
|
||||
let sub_span = self.span_utils.span_for_last_ident(expr.span);
|
||||
return Some(Data::VariableRefData(VariableRefData {
|
||||
name: get_ident(ident.node).to_string(),
|
||||
name: ident.node.to_string(),
|
||||
span: sub_span.unwrap(),
|
||||
scope: self.enclosing_scope(expr.id),
|
||||
ref_id: f.id,
|
||||
@ -454,7 +453,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
|
||||
self.tcx.sess.span_bug(expr.span,
|
||||
&format!("Couldn't find field {} on {:?}",
|
||||
&get_ident(ident.node), ty))
|
||||
ident.node, ty))
|
||||
}
|
||||
_ => {
|
||||
debug!("Expected struct type, found {:?}", ty);
|
||||
@ -613,7 +612,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||
parent: NodeId)
|
||||
-> VariableRefData {
|
||||
let fields = self.tcx.lookup_struct_fields(struct_id);
|
||||
let field_name = get_ident(field_ref.ident.node).to_string();
|
||||
let field_name = field_ref.ident.node.to_string();
|
||||
for f in &fields {
|
||||
if f.name == field_ref.ident.node.name {
|
||||
// We don't really need a sub-span here, but no harm done
|
||||
@ -687,7 +686,7 @@ impl<'v> Visitor<'v> for PathCollector {
|
||||
}
|
||||
ast::PatIdent(bm, ref path1, _) => {
|
||||
debug!("PathCollector, visit ident in pat {}: {:?} {:?}",
|
||||
token::get_ident(path1.node),
|
||||
path1.node,
|
||||
p.span,
|
||||
path1.span);
|
||||
let immut = match bm {
|
||||
|
@ -586,7 +586,7 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> {
|
||||
pub fn sess(&self) -> &'blk Session { self.fcx.ccx.sess() }
|
||||
|
||||
pub fn name(&self, name: ast::Name) -> String {
|
||||
token::get_name(name).to_string()
|
||||
name.to_string()
|
||||
}
|
||||
|
||||
pub fn node_id_to_string(&self, id: ast::NodeId) -> String {
|
||||
|
@ -1152,7 +1152,7 @@ impl<'tcx> StructMemberDescriptionFactory<'tcx> {
|
||||
let name = if field.name == special_idents::unnamed_field.name {
|
||||
format!("__{}", i)
|
||||
} else {
|
||||
token::get_name(field.name).to_string()
|
||||
field.name.to_string()
|
||||
};
|
||||
|
||||
let offset = if self.is_simd {
|
||||
@ -1307,7 +1307,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
|
||||
describe_enum_variant(cx,
|
||||
self.enum_type,
|
||||
struct_def,
|
||||
&*(*self.variants)[i],
|
||||
&*self.variants[i],
|
||||
discriminant_info,
|
||||
self.containing_scope,
|
||||
self.span);
|
||||
@ -1340,7 +1340,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
|
||||
describe_enum_variant(cx,
|
||||
self.enum_type,
|
||||
struct_def,
|
||||
&*(*self.variants)[0],
|
||||
&*self.variants[0],
|
||||
NoDiscriminant,
|
||||
self.containing_scope,
|
||||
self.span);
|
||||
@ -1369,8 +1369,8 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
|
||||
// DWARF representation of enums uniform.
|
||||
|
||||
// First create a description of the artificial wrapper struct:
|
||||
let non_null_variant = &(*self.variants)[non_null_variant_index as usize];
|
||||
let non_null_variant_name = token::get_name(non_null_variant.name);
|
||||
let non_null_variant = &self.variants[non_null_variant_index as usize];
|
||||
let non_null_variant_name = non_null_variant.name.as_str();
|
||||
|
||||
// The llvm type and metadata of the pointer
|
||||
let non_null_llvm_type = type_of::type_of(cx, nnty);
|
||||
@ -1385,7 +1385,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
|
||||
// MemberDescription of the struct's single field.
|
||||
let sole_struct_member_description = MemberDescription {
|
||||
name: match non_null_variant.arg_names {
|
||||
Some(ref names) => token::get_name(names[0]).to_string(),
|
||||
Some(ref names) => names[0].to_string(),
|
||||
None => "__0".to_string()
|
||||
},
|
||||
llvm_type: non_null_llvm_type,
|
||||
@ -1415,7 +1415,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
|
||||
// Encode the information about the null variant in the union
|
||||
// member's name.
|
||||
let null_variant_index = (1 - non_null_variant_index) as usize;
|
||||
let null_variant_name = token::get_name((*self.variants)[null_variant_index].name);
|
||||
let null_variant_name = self.variants[null_variant_index].name;
|
||||
let union_member_name = format!("RUST$ENCODED$ENUM${}${}",
|
||||
0,
|
||||
null_variant_name);
|
||||
@ -1440,7 +1440,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
|
||||
describe_enum_variant(cx,
|
||||
self.enum_type,
|
||||
struct_def,
|
||||
&*(*self.variants)[nndiscr as usize],
|
||||
&*self.variants[nndiscr as usize],
|
||||
OptimizedDiscriminant,
|
||||
self.containing_scope,
|
||||
self.span);
|
||||
@ -1456,7 +1456,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
|
||||
// Encode the information about the null variant in the union
|
||||
// member's name.
|
||||
let null_variant_index = (1 - nndiscr) as usize;
|
||||
let null_variant_name = token::get_name((*self.variants)[null_variant_index].name);
|
||||
let null_variant_name = self.variants[null_variant_index].name;
|
||||
let discrfield = discrfield.iter()
|
||||
.skip(1)
|
||||
.map(|x| x.to_string())
|
||||
@ -1534,18 +1534,17 @@ fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
struct_def.packed);
|
||||
// Could do some consistency checks here: size, align, field count, discr type
|
||||
|
||||
let variant_name = token::get_name(variant_info.name);
|
||||
let variant_name = &variant_name;
|
||||
let variant_name = variant_info.name.as_str();
|
||||
let unique_type_id = debug_context(cx).type_map
|
||||
.borrow_mut()
|
||||
.get_unique_type_id_of_enum_variant(
|
||||
cx,
|
||||
enum_type,
|
||||
variant_name);
|
||||
&variant_name);
|
||||
|
||||
let metadata_stub = create_struct_stub(cx,
|
||||
variant_llvm_type,
|
||||
variant_name,
|
||||
&variant_name,
|
||||
unique_type_id,
|
||||
containing_scope);
|
||||
|
||||
@ -1553,7 +1552,7 @@ fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
let mut arg_names: Vec<_> = match variant_info.arg_names {
|
||||
Some(ref names) => {
|
||||
names.iter()
|
||||
.map(|&name| token::get_name(name).to_string())
|
||||
.map(|name| name.to_string())
|
||||
.collect()
|
||||
}
|
||||
None => {
|
||||
@ -1609,7 +1608,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
let enumerators_metadata: Vec<DIDescriptor> = variants
|
||||
.iter()
|
||||
.map(|v| {
|
||||
let token = token::get_name(v.name);
|
||||
let token = v.name.as_str();
|
||||
let name = CString::new(token.as_bytes()).unwrap();
|
||||
unsafe {
|
||||
llvm::LLVMDIBuilderCreateEnumerator(
|
||||
@ -1723,7 +1722,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
csearch::get_item_path(cx.tcx(), def_id).last().unwrap().name()
|
||||
};
|
||||
|
||||
token::get_name(name)
|
||||
name.as_str()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1907,7 +1906,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
|
||||
let variable_type = cx.tcx().node_id_to_type(node_id);
|
||||
let type_metadata = type_metadata(cx, variable_type, span);
|
||||
let namespace_node = namespace_for_item(cx, ast_util::local_def(node_id));
|
||||
let var_name = token::get_name(name).to_string();
|
||||
let var_name = name.to_string();
|
||||
let linkage_name =
|
||||
namespace_node.mangled_name_of_contained_item(&var_name[..]);
|
||||
let var_scope = namespace_node.scope;
|
||||
|
@ -333,7 +333,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
// Get_template_parameters() will append a `<...>` clause to the function
|
||||
// name if necessary.
|
||||
let mut function_name = String::from(&*token::get_name(name));
|
||||
let mut function_name = name.to_string();
|
||||
let template_parameters = get_template_parameters(cx,
|
||||
generics,
|
||||
param_substs,
|
||||
@ -494,7 +494,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
actual_self_type,
|
||||
codemap::DUMMY_SP);
|
||||
|
||||
let name = token::get_name(special_idents::type_self.name);
|
||||
let name = special_idents::type_self.name.as_str();
|
||||
|
||||
let name = CString::new(name.as_bytes()).unwrap();
|
||||
let param_metadata = unsafe {
|
||||
@ -529,8 +529,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
// Again, only create type information if full debuginfo is enabled
|
||||
if cx.sess().opts.debuginfo == FullDebugInfo {
|
||||
let actual_type_metadata = type_metadata(cx, actual_type, codemap::DUMMY_SP);
|
||||
let ident = token::get_ident(ident);
|
||||
let name = CString::new(ident.as_bytes()).unwrap();
|
||||
let name = CString::new(ident.name.as_str().as_bytes()).unwrap();
|
||||
let param_metadata = unsafe {
|
||||
llvm::LLVMDIBuilderCreateTemplateTypeParameter(
|
||||
DIB(cx),
|
||||
@ -563,7 +562,6 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
let filename = span_start(cx, span).file.name.clone();
|
||||
let file_metadata = file_metadata(cx, &filename[..]);
|
||||
|
||||
let name = token::get_name(variable_name);
|
||||
let loc = span_start(cx, span);
|
||||
let type_metadata = type_metadata(cx, variable_type, span);
|
||||
|
||||
@ -573,7 +571,7 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
CapturedVariable => (0, DW_TAG_auto_variable)
|
||||
};
|
||||
|
||||
let name = CString::new(name.as_bytes()).unwrap();
|
||||
let name = CString::new(variable_name.as_str().as_bytes()).unwrap();
|
||||
match (variable_access, &[][..]) {
|
||||
(DirectVariable { alloca }, address_operations) |
|
||||
(IndirectVariable {alloca, address_operations}, _) => {
|
||||
|
@ -36,14 +36,14 @@ impl NamespaceTreeNode {
|
||||
Some(ref parent) => fill_nested(&*parent.upgrade().unwrap(), output),
|
||||
None => {}
|
||||
}
|
||||
let string = token::get_name(node.name);
|
||||
output.push_str(&format!("{}", string.len()));
|
||||
let string = node.name.as_str();
|
||||
output.push_str(&string.len().to_string());
|
||||
output.push_str(&string);
|
||||
}
|
||||
|
||||
let mut name = String::from("_ZN");
|
||||
fill_nested(self, &mut name);
|
||||
name.push_str(&format!("{}", item_name.len()));
|
||||
name.push_str(&item_name.len().to_string());
|
||||
name.push_str(item_name);
|
||||
name.push('E');
|
||||
name
|
||||
@ -93,7 +93,7 @@ pub fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc<Namespace
|
||||
Some(ref node) => node.scope,
|
||||
None => ptr::null_mut()
|
||||
};
|
||||
let namespace_name = token::get_name(name);
|
||||
let namespace_name = name.as_str();
|
||||
let namespace_name = CString::new(namespace_name.as_bytes()).unwrap();
|
||||
let scope = unsafe {
|
||||
llvm::LLVMDIBuilderCreateNameSpace(
|
||||
|
@ -17,7 +17,6 @@ use middle::subst::{self, Substs};
|
||||
use middle::ty::{self, Ty};
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
|
||||
|
||||
// Compute the name of the type as it should be stored in debuginfo. Does not do
|
||||
@ -179,8 +178,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
let mut path_element_count = 0;
|
||||
for path_element in path {
|
||||
let name = token::get_name(path_element.name());
|
||||
output.push_str(&name);
|
||||
output.push_str(&path_element.name().as_str());
|
||||
output.push_str("::");
|
||||
path_element_count += 1;
|
||||
}
|
||||
@ -192,10 +190,8 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
output.pop();
|
||||
output.pop();
|
||||
} else {
|
||||
let name = token::get_name(path.last()
|
||||
.expect("debuginfo: Empty item path?")
|
||||
.name());
|
||||
output.push_str(&name);
|
||||
let name = path.last().expect("debuginfo: Empty item path?").name();
|
||||
output.push_str(&name.as_str());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ use syntax::abi::{Cdecl, Aapcs, C, Win64, Abi};
|
||||
use syntax::abi::{RustIntrinsic, Rust, RustCall, Stdcall, Fastcall, System};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token::{InternedString, special_idents};
|
||||
use syntax::parse::token;
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::print::pprust;
|
||||
@ -902,7 +901,7 @@ pub fn link_name(i: &ast::ForeignItem) -> InternedString {
|
||||
Some(ln) => ln.clone(),
|
||||
None => match weak_lang_items::link_name(&i.attrs) {
|
||||
Some(name) => name,
|
||||
None => token::get_ident(i.ident),
|
||||
None => i.ident.name.as_str(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
|
||||
pub fn get_simple_intrinsic(ccx: &CrateContext, item: &ast::ForeignItem) -> Option<ValueRef> {
|
||||
let name = match &token::get_ident(item.ident)[..] {
|
||||
let name = match &*item.ident.name.as_str() {
|
||||
"sqrtf32" => "llvm.sqrt.f32",
|
||||
"sqrtf64" => "llvm.sqrt.f64",
|
||||
"powif32" => "llvm.powi.f32",
|
||||
@ -171,10 +171,10 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
_ => panic!("expected bare_fn in trans_intrinsic_call")
|
||||
};
|
||||
let foreign_item = tcx.map.expect_foreign_item(node);
|
||||
let name = token::get_ident(foreign_item.ident);
|
||||
let name = foreign_item.ident.name.as_str();
|
||||
|
||||
// For `transmute` we can just trans the input expr directly into dest
|
||||
if &name[..] == "transmute" {
|
||||
if name == "transmute" {
|
||||
let llret_ty = type_of::type_of(ccx, ret_ty.unwrap());
|
||||
match args {
|
||||
callee::ArgExprs(arg_exprs) => {
|
||||
@ -271,7 +271,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
// (the first argument) and then trans the source value (the
|
||||
// second argument) directly into the resulting destination
|
||||
// address.
|
||||
if &name[..] == "move_val_init" {
|
||||
if name == "move_val_init" {
|
||||
if let callee::ArgExprs(ref exprs) = args {
|
||||
let (dest_expr, source_expr) = if exprs.len() != 2 {
|
||||
ccx.sess().bug("expected two exprs as arguments for `move_val_init` intrinsic");
|
||||
@ -354,7 +354,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
fcx.scopes.borrow_mut().last_mut().unwrap().drop_non_lifetime_clean();
|
||||
|
||||
// These are the only intrinsic functions that diverge.
|
||||
if &name[..] == "abort" {
|
||||
if name == "abort" {
|
||||
let llfn = ccx.get_intrinsic(&("llvm.trap"));
|
||||
Call(bcx, llfn, &[], None, call_debug_location);
|
||||
fcx.pop_and_trans_custom_cleanup_scope(bcx, cleanup_scope);
|
||||
@ -387,7 +387,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
};
|
||||
|
||||
let simple = get_simple_intrinsic(ccx, &*foreign_item);
|
||||
let llval = match (simple, &name[..]) {
|
||||
let llval = match (simple, &*name) {
|
||||
(Some(llfn), _) => {
|
||||
Call(bcx, llfn, &llargs, None, call_debug_location)
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ use trans::type_of::*;
|
||||
use middle::ty::{self, Ty, HasTypeFlags};
|
||||
use middle::ty::MethodCall;
|
||||
|
||||
use syntax::parse::token;
|
||||
use syntax::{ast, attr, visit};
|
||||
use syntax::codemap::DUMMY_SP;
|
||||
use syntax::ptr::P;
|
||||
@ -175,7 +174,7 @@ pub fn trans_static_method_callee<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
csearch::get_item_path(tcx, method_id).last().unwrap().name()
|
||||
};
|
||||
debug!("trans_static_method_callee: method_id={:?}, expr_id={}, \
|
||||
name={}", method_id, expr_id, token::get_name(mname));
|
||||
name={}", method_id, expr_id, mname);
|
||||
|
||||
// Find the substitutions for the fn itself. This includes
|
||||
// type parameters that belong to the trait but also some that
|
||||
|
@ -903,7 +903,7 @@ fn ast_type_binding_to_poly_projection_predicate<'tcx>(
|
||||
let candidate = try!(one_bound_for_assoc_type(tcx,
|
||||
candidates,
|
||||
&trait_ref.to_string(),
|
||||
&token::get_name(binding.item_name),
|
||||
&binding.item_name.as_str(),
|
||||
binding.span));
|
||||
|
||||
Ok(ty::Binder(ty::ProjectionPredicate { // <-------------------------+
|
||||
@ -1150,8 +1150,8 @@ fn find_bound_for_assoc_item<'tcx>(this: &AstConv<'tcx>,
|
||||
|
||||
one_bound_for_assoc_type(tcx,
|
||||
suitable_bounds,
|
||||
&token::get_name(ty_param_name),
|
||||
&token::get_name(assoc_name),
|
||||
&ty_param_name.as_str(),
|
||||
&assoc_name.as_str(),
|
||||
span)
|
||||
}
|
||||
|
||||
@ -1236,7 +1236,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
|
||||
match one_bound_for_assoc_type(tcx,
|
||||
candidates,
|
||||
"Self",
|
||||
&token::get_name(assoc_name),
|
||||
&assoc_name.as_str(),
|
||||
span) {
|
||||
Ok(bound) => bound,
|
||||
Err(ErrorReported) => return (tcx.types.err, ty_path_def),
|
||||
@ -1269,7 +1269,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
|
||||
span,
|
||||
&ty.to_string(),
|
||||
"Trait",
|
||||
&token::get_name(assoc_name));
|
||||
&assoc_name.as_str());
|
||||
return (tcx.types.err, ty_path_def);
|
||||
}
|
||||
};
|
||||
@ -1320,7 +1320,7 @@ fn qpath_to_ty<'tcx>(this: &AstConv<'tcx>,
|
||||
span,
|
||||
"Type",
|
||||
&path_str,
|
||||
&token::get_ident(item_segment.identifier));
|
||||
&item_segment.identifier.name.as_str());
|
||||
return tcx.types.err;
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,6 @@ use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
use syntax::ast;
|
||||
use syntax::ast_util;
|
||||
use syntax::codemap::{Span, Spanned};
|
||||
use syntax::parse::token;
|
||||
use syntax::print::pprust;
|
||||
use syntax::ptr::P;
|
||||
|
||||
@ -736,10 +735,10 @@ pub fn check_struct_pat_fields<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
||||
Occupied(occupied) => {
|
||||
span_err!(tcx.sess, span, E0025,
|
||||
"field `{}` bound multiple times in the pattern",
|
||||
token::get_ident(field.ident));
|
||||
field.ident);
|
||||
span_note!(tcx.sess, *occupied.get(),
|
||||
"field `{}` previously bound here",
|
||||
token::get_ident(field.ident));
|
||||
field.ident);
|
||||
tcx.types.err
|
||||
}
|
||||
Vacant(vacant) => {
|
||||
@ -749,7 +748,7 @@ pub fn check_struct_pat_fields<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
||||
span_err!(tcx.sess, span, E0026,
|
||||
"struct `{}` does not have a field named `{}`",
|
||||
tcx.item_path_str(struct_id),
|
||||
token::get_ident(field.ident));
|
||||
field.ident);
|
||||
tcx.types.err
|
||||
})
|
||||
}
|
||||
@ -767,7 +766,7 @@ pub fn check_struct_pat_fields<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
||||
.filter(|field| !used_fields.contains_key(&field.name)) {
|
||||
span_err!(tcx.sess, span, E0027,
|
||||
"pattern does not mention field `{}`",
|
||||
token::get_name(field.name));
|
||||
field.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ use middle::subst::{self, Subst, Substs, VecPerParamSpace};
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token;
|
||||
|
||||
use super::assoc;
|
||||
|
||||
@ -85,7 +84,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
span_err!(tcx.sess, impl_m_span, E0049,
|
||||
"method `{}` has {} type parameter{} \
|
||||
but its trait declaration has {} type parameter{}",
|
||||
token::get_name(trait_m.name),
|
||||
trait_m.name,
|
||||
num_impl_m_type_params,
|
||||
if num_impl_m_type_params == 1 {""} else {"s"},
|
||||
num_trait_m_type_params,
|
||||
@ -97,7 +96,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
span_err!(tcx.sess, impl_m_span, E0050,
|
||||
"method `{}` has {} parameter{} \
|
||||
but the declaration in trait `{}` has {}",
|
||||
token::get_name(trait_m.name),
|
||||
trait_m.name,
|
||||
impl_m.fty.sig.0.inputs.len(),
|
||||
if impl_m.fty.sig.0.inputs.len() == 1 {""} else {"s"},
|
||||
tcx.item_path_str(trait_m.def_id),
|
||||
@ -337,7 +336,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
trait_fty);
|
||||
span_err!(tcx.sess, impl_m_span, E0053,
|
||||
"method `{}` has an incompatible type for trait: {}",
|
||||
token::get_name(trait_m.name),
|
||||
trait_m.name,
|
||||
terr);
|
||||
return;
|
||||
}
|
||||
@ -401,7 +400,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
span_err!(tcx.sess, span, E0195,
|
||||
"lifetime parameters or bounds on method `{}` do \
|
||||
not match the trait declaration",
|
||||
token::get_name(impl_m.name));
|
||||
impl_m.name);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -484,7 +483,7 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
span_err!(tcx.sess, impl_c_span, E0326,
|
||||
"implemented const `{}` has an incompatible type for \
|
||||
trait: {}",
|
||||
token::get_name(trait_c.name),
|
||||
trait_c.name,
|
||||
terr);
|
||||
return;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ use syntax::ast_util::{self, local_def};
|
||||
use syntax::codemap::{self, Span};
|
||||
use syntax::feature_gate::emit_feature_err;
|
||||
use syntax::owned_slice::OwnedSlice;
|
||||
use syntax::parse::token;
|
||||
use syntax::parse::token::{self, InternedString};
|
||||
use syntax::print::pprust;
|
||||
use syntax::ptr::P;
|
||||
use syntax::visit::{self, Visitor};
|
||||
@ -505,7 +505,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
|
||||
traits::VariableType(p.id));
|
||||
|
||||
debug!("Pattern binding {} is assigned to {} with type {:?}",
|
||||
token::get_ident(path1.node),
|
||||
path1.node,
|
||||
self.fcx.infcx().ty_to_string(
|
||||
self.fcx.inh.locals.borrow().get(&p.id).unwrap().clone()),
|
||||
var_ty);
|
||||
@ -662,7 +662,7 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
|
||||
}
|
||||
ast::ItemFn(..) => {} // entirely within check_item_body
|
||||
ast::ItemImpl(_, _, _, _, _, ref impl_items) => {
|
||||
debug!("ItemImpl {} with id {}", token::get_ident(it.ident), it.id);
|
||||
debug!("ItemImpl {} with id {}", it.ident, it.id);
|
||||
match ccx.tcx.impl_trait_ref(local_def(it.id)) {
|
||||
Some(impl_trait_ref) => {
|
||||
check_impl_items_against_trait(ccx,
|
||||
@ -718,7 +718,7 @@ pub fn check_item_body<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
|
||||
check_bare_fn(ccx, &**decl, &**body, it.id, it.span, fn_pty.ty, param_env);
|
||||
}
|
||||
ast::ItemImpl(_, _, _, _, _, ref impl_items) => {
|
||||
debug!("ItemImpl {} with id {}", token::get_ident(it.ident), it.id);
|
||||
debug!("ItemImpl {} with id {}", it.ident, it.id);
|
||||
|
||||
let impl_pty = ccx.tcx.lookup_item_type(ast_util::local_def(it.id));
|
||||
|
||||
@ -796,14 +796,14 @@ fn check_trait_on_unimplemented<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
Position::ArgumentNamed(s) if s == "Self" => (),
|
||||
// So is `{A}` if A is a type parameter
|
||||
Position::ArgumentNamed(s) => match types.iter().find(|t| {
|
||||
t.ident.as_str() == s
|
||||
t.ident.name == s
|
||||
}) {
|
||||
Some(_) => (),
|
||||
None => {
|
||||
span_err!(ccx.tcx.sess, attr.span, E0230,
|
||||
"there is no type parameter \
|
||||
{} on trait {}",
|
||||
s, item.ident.as_str());
|
||||
s, item.ident);
|
||||
}
|
||||
},
|
||||
// `{:1}` and `{}` are not to be used
|
||||
@ -865,7 +865,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
// This is checked by resolve
|
||||
tcx.sess.span_bug(impl_item.span,
|
||||
&format!("impl-item `{}` is not a member of `{:?}`",
|
||||
token::get_name(ty_impl_item.name()),
|
||||
ty_impl_item.name(),
|
||||
impl_trait_ref));
|
||||
});
|
||||
match impl_item.node {
|
||||
@ -886,7 +886,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
span_err!(tcx.sess, impl_item.span, E0323,
|
||||
"item `{}` is an associated const, \
|
||||
which doesn't match its trait `{:?}`",
|
||||
token::get_name(impl_const.name),
|
||||
impl_const.name,
|
||||
impl_trait_ref)
|
||||
}
|
||||
}
|
||||
@ -909,7 +909,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
span_err!(tcx.sess, impl_item.span, E0324,
|
||||
"item `{}` is an associated method, \
|
||||
which doesn't match its trait `{:?}`",
|
||||
token::get_name(impl_method.name),
|
||||
impl_method.name,
|
||||
impl_trait_ref)
|
||||
}
|
||||
}
|
||||
@ -927,7 +927,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
span_err!(tcx.sess, impl_item.span, E0325,
|
||||
"item `{}` is an associated type, \
|
||||
which doesn't match its trait `{:?}`",
|
||||
token::get_name(impl_type.name),
|
||||
impl_type.name,
|
||||
impl_trait_ref)
|
||||
}
|
||||
}
|
||||
@ -1009,7 +1009,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
span_err!(tcx.sess, impl_span, E0046,
|
||||
"not all trait items implemented, missing: `{}`",
|
||||
missing_items.iter()
|
||||
.map(<ast::Name>::as_str)
|
||||
.map(|name| name.to_string())
|
||||
.collect::<Vec<_>>().join("`, `"))
|
||||
}
|
||||
|
||||
@ -1018,9 +1018,9 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
span_err!(tcx.sess, invalidator.span, E0399,
|
||||
"the following trait items need to be reimplemented \
|
||||
as `{}` was overridden: `{}`",
|
||||
invalidator.ident.as_str(),
|
||||
invalidator.ident,
|
||||
invalidated_items.iter()
|
||||
.map(<ast::Name>::as_str)
|
||||
.map(|name| name.to_string())
|
||||
.collect::<Vec<_>>().join("`, `"))
|
||||
}
|
||||
}
|
||||
@ -2901,7 +2901,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
||||
field.span,
|
||||
|actual| {
|
||||
format!("attempted to take value of method `{}` on type \
|
||||
`{}`", token::get_ident(field.node), actual)
|
||||
`{}`", field.node, actual)
|
||||
},
|
||||
expr_t, None);
|
||||
|
||||
@ -2915,7 +2915,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
||||
format!("attempted access of field `{}` on \
|
||||
type `{}`, but no field with that \
|
||||
name was found",
|
||||
token::get_ident(field.node),
|
||||
field.node,
|
||||
actual)
|
||||
},
|
||||
expr_t, None);
|
||||
@ -2931,9 +2931,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
||||
fn suggest_field_names<'tcx>(id : DefId,
|
||||
field : &ast::SpannedIdent,
|
||||
tcx : &ty::ctxt<'tcx>,
|
||||
skip : Vec<&str>) {
|
||||
let ident = token::get_ident(field.node);
|
||||
let name = &ident;
|
||||
skip : Vec<InternedString>) {
|
||||
let name = field.node.name.as_str();
|
||||
// only find fits with at least one matching letter
|
||||
let mut best_dist = name.len();
|
||||
let fields = tcx.lookup_struct_fields(id);
|
||||
@ -2941,14 +2940,14 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
||||
for elem in &fields {
|
||||
let n = elem.name.as_str();
|
||||
// ignore already set fields
|
||||
if skip.iter().any(|&x| x == n) {
|
||||
if skip.iter().any(|x| *x == n) {
|
||||
continue;
|
||||
}
|
||||
// ignore private fields from non-local crates
|
||||
if id.krate != ast::LOCAL_CRATE && elem.vis != Visibility::Public {
|
||||
continue;
|
||||
}
|
||||
let dist = lev_distance(n, name);
|
||||
let dist = lev_distance(&n, &name);
|
||||
if dist < best_dist {
|
||||
best = Some(n);
|
||||
best_dist = dist;
|
||||
@ -3061,12 +3060,12 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
||||
class_id);
|
||||
format!("struct variant `{}::{}` has no field named `{}`",
|
||||
actual, variant_type.name.as_str(),
|
||||
token::get_ident(field.ident.node))
|
||||
field.ident.node)
|
||||
}
|
||||
None => {
|
||||
format!("structure `{}` has no field named `{}`",
|
||||
actual,
|
||||
token::get_ident(field.ident.node))
|
||||
field.ident.node)
|
||||
}
|
||||
},
|
||||
struct_ty,
|
||||
@ -3083,7 +3082,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
||||
Some((_, true)) => {
|
||||
span_err!(fcx.tcx().sess, field.ident.span, E0062,
|
||||
"field `{}` specified more than once",
|
||||
token::get_ident(field.ident.node));
|
||||
field.ident.node);
|
||||
error_happened = true;
|
||||
}
|
||||
Some((field_id, false)) => {
|
||||
@ -3117,7 +3116,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
||||
let (_, seen) = *class_field_map.get(&name).unwrap();
|
||||
if !seen {
|
||||
missing_fields.push(
|
||||
format!("`{}`", &token::get_name(name)))
|
||||
format!("`{}`", name))
|
||||
}
|
||||
}
|
||||
|
||||
@ -5059,7 +5058,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
if !*b {
|
||||
span_err!(ccx.tcx.sess, span, E0091,
|
||||
"type parameter `{}` is unused",
|
||||
token::get_ident(tps[i].ident));
|
||||
tps[i].ident);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5073,7 +5072,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
||||
}
|
||||
|
||||
let tcx = ccx.tcx;
|
||||
let name = token::get_ident(it.ident);
|
||||
let name = it.ident.name.as_str();
|
||||
let (n_tps, inputs, output) = if name.starts_with("atomic_") {
|
||||
let split : Vec<&str> = name.split('_').collect();
|
||||
assert!(split.len() >= 2, "Atomic intrinsic not correct format");
|
||||
|
@ -23,7 +23,7 @@ use std::collections::HashSet;
|
||||
use syntax::ast;
|
||||
use syntax::ast_util::local_def;
|
||||
use syntax::codemap::{DUMMY_SP, Span};
|
||||
use syntax::parse::token::{self, special_idents};
|
||||
use syntax::parse::token::special_idents;
|
||||
use syntax::visit;
|
||||
use syntax::visit::Visitor;
|
||||
|
||||
@ -422,7 +422,7 @@ fn reject_shadowing_type_parameters<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
if impl_params.contains(&method_param.name) {
|
||||
span_err!(tcx.sess, span, E0194,
|
||||
"type parameter `{}` shadows another type parameter of the same name",
|
||||
token::get_name(method_param.name));
|
||||
method_param.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -383,14 +383,14 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
|
||||
"the trait `Copy` may not be \
|
||||
implemented for this type; field \
|
||||
`{}` does not implement `Copy`",
|
||||
token::get_name(name))
|
||||
name)
|
||||
}
|
||||
Err(ty::VariantDoesNotImplementCopy(name)) => {
|
||||
span_err!(tcx.sess, span, E0205,
|
||||
"the trait `Copy` may not be \
|
||||
implemented for this type; variant \
|
||||
`{}` does not implement `Copy`",
|
||||
token::get_name(name))
|
||||
name)
|
||||
}
|
||||
Err(ty::TypeIsStructural) => {
|
||||
span_err!(tcx.sess, span, E0206,
|
||||
|
@ -91,7 +91,6 @@ use syntax::ast;
|
||||
use syntax::ast_util::local_def;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token::special_idents;
|
||||
use syntax::parse::token;
|
||||
use syntax::ptr::P;
|
||||
use syntax::visit;
|
||||
|
||||
@ -795,7 +794,7 @@ fn ensure_no_ty_param_bounds(ccx: &CrateCtxt,
|
||||
|
||||
fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
|
||||
let tcx = ccx.tcx;
|
||||
debug!("convert: item {} with id {}", token::get_ident(it.ident), it.id);
|
||||
debug!("convert: item {} with id {}", it.ident, it.id);
|
||||
match it.node {
|
||||
// These don't define types.
|
||||
ast::ItemExternCrate(_) | ast::ItemUse(_) |
|
||||
@ -1086,7 +1085,7 @@ fn convert_struct<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
Some(prev_span) => {
|
||||
span_err!(tcx.sess, f.span, E0124,
|
||||
"field `{}` is already declared",
|
||||
token::get_name(result.name));
|
||||
result.name);
|
||||
span_note!(tcx.sess, *prev_span, "previously declared here");
|
||||
true
|
||||
},
|
||||
|
@ -745,19 +745,19 @@ impl Lifetime {
|
||||
|
||||
impl Clean<Lifetime> for ast::Lifetime {
|
||||
fn clean(&self, _: &DocContext) -> Lifetime {
|
||||
Lifetime(token::get_name(self.name).to_string())
|
||||
Lifetime(self.name.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl Clean<Lifetime> for ast::LifetimeDef {
|
||||
fn clean(&self, _: &DocContext) -> Lifetime {
|
||||
Lifetime(token::get_name(self.lifetime.name).to_string())
|
||||
Lifetime(self.lifetime.name.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl Clean<Lifetime> for ty::RegionParameterDef {
|
||||
fn clean(&self, _: &DocContext) -> Lifetime {
|
||||
Lifetime(token::get_name(self.name).to_string())
|
||||
Lifetime(self.name.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
@ -766,7 +766,7 @@ impl Clean<Option<Lifetime>> for ty::Region {
|
||||
match *self {
|
||||
ty::ReStatic => Some(Lifetime::statik()),
|
||||
ty::ReLateBound(_, ty::BrNamed(_, name)) =>
|
||||
Some(Lifetime(token::get_name(name).to_string())),
|
||||
Some(Lifetime(name.to_string())),
|
||||
ty::ReEarlyBound(ref data) => Some(Lifetime(data.name.clean(cx))),
|
||||
|
||||
ty::ReLateBound(..) |
|
||||
@ -1695,7 +1695,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
|
||||
|
||||
ty::TyProjection(ref data) => data.clean(cx),
|
||||
|
||||
ty::TyParam(ref p) => Generic(token::get_name(p.name).to_string()),
|
||||
ty::TyParam(ref p) => Generic(p.name.to_string()),
|
||||
|
||||
ty::TyClosure(..) => Tuple(vec![]), // FIXME(pcwalton)
|
||||
|
||||
@ -2048,7 +2048,7 @@ impl Clean<PathSegment> for ast::PathSegment {
|
||||
fn path_to_string(p: &ast::Path) -> String {
|
||||
let mut s = String::new();
|
||||
let mut first = true;
|
||||
for i in p.segments.iter().map(|x| token::get_ident(x.identifier)) {
|
||||
for i in p.segments.iter().map(|x| x.identifier.name.as_str()) {
|
||||
if !first || p.global {
|
||||
s.push_str("::");
|
||||
} else {
|
||||
@ -2061,13 +2061,13 @@ fn path_to_string(p: &ast::Path) -> String {
|
||||
|
||||
impl Clean<String> for ast::Ident {
|
||||
fn clean(&self, _: &DocContext) -> String {
|
||||
token::get_ident(*self).to_string()
|
||||
self.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl Clean<String> for ast::Name {
|
||||
fn clean(&self, _: &DocContext) -> String {
|
||||
token::get_name(*self).to_string()
|
||||
self.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
@ -2532,14 +2532,14 @@ fn name_from_pat(p: &ast::Pat) -> String {
|
||||
match p.node {
|
||||
PatWild(PatWildSingle) => "_".to_string(),
|
||||
PatWild(PatWildMulti) => "..".to_string(),
|
||||
PatIdent(_, ref p, _) => token::get_ident(p.node).to_string(),
|
||||
PatIdent(_, ref p, _) => p.node.to_string(),
|
||||
PatEnum(ref p, _) => path_to_string(p),
|
||||
PatQPath(..) => panic!("tried to get argument name from PatQPath, \
|
||||
which is not allowed in function arguments"),
|
||||
PatStruct(ref name, ref fields, etc) => {
|
||||
format!("{} {{ {}{} }}", path_to_string(name),
|
||||
fields.iter().map(|&Spanned { node: ref fp, .. }|
|
||||
format!("{}: {}", fp.ident.as_str(), name_from_pat(&*fp.pat)))
|
||||
format!("{}: {}", fp.ident, name_from_pat(&*fp.pat)))
|
||||
.collect::<Vec<String>>().join(", "),
|
||||
if etc { ", ..." } else { "" }
|
||||
)
|
||||
@ -2603,7 +2603,7 @@ fn resolve_type(cx: &DocContext,
|
||||
ast::TyFloat(ast::TyF64) => return Primitive(F64),
|
||||
},
|
||||
def::DefSelfTy(..) if path.segments.len() == 1 => {
|
||||
return Generic(token::get_name(special_idents::type_self.name).to_string());
|
||||
return Generic(special_idents::type_self.name.to_string());
|
||||
}
|
||||
def::DefSelfTy(..) | def::DefTyParam(..) => true,
|
||||
_ => false,
|
||||
|
@ -75,7 +75,7 @@ fn doit(sess: &parse::ParseSess, mut lexer: lexer::StringReader,
|
||||
continue
|
||||
},
|
||||
token::Shebang(s) => {
|
||||
try!(write!(out, "{}", Escape(s.as_str())));
|
||||
try!(write!(out, "{}", Escape(&s.as_str())));
|
||||
continue
|
||||
},
|
||||
// If this '&' token is directly adjacent to another token, assume
|
||||
@ -141,7 +141,7 @@ fn doit(sess: &parse::ParseSess, mut lexer: lexer::StringReader,
|
||||
|
||||
// keywords are also included in the identifier set
|
||||
token::Ident(ident, _is_mod_sep) => {
|
||||
match &token::get_ident(ident)[..] {
|
||||
match &*ident.name.as_str() {
|
||||
"ref" | "mut" => "kw-2",
|
||||
|
||||
"self" => "self",
|
||||
|
@ -87,10 +87,6 @@ pub struct Ident {
|
||||
impl Ident {
|
||||
/// Construct an identifier with the given name and an empty context:
|
||||
pub fn new(name: Name) -> Ident { Ident {name: name, ctxt: EMPTY_CTXT}}
|
||||
|
||||
pub fn as_str<'a>(&'a self) -> &'a str {
|
||||
self.name.as_str()
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Ident {
|
||||
@ -108,13 +104,13 @@ impl fmt::Display for Ident {
|
||||
impl fmt::Debug for Name {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let Name(nm) = *self;
|
||||
write!(f, "{:?}({})", token::get_name(*self), nm)
|
||||
write!(f, "{}({})", self, nm)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Name {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Display::fmt(&token::get_name(*self), f)
|
||||
fmt::Display::fmt(&self.as_str(), f)
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,13 +130,10 @@ impl PartialEq for Ident {
|
||||
// one example and its non-hygienic counterpart would be:
|
||||
// syntax::parse::token::Token::mtwt_eq
|
||||
// syntax::ext::tt::macro_parser::token_name_eq
|
||||
panic!("not allowed to compare these idents: {}, {}. \
|
||||
panic!("not allowed to compare these idents: {:?}, {:?}. \
|
||||
Probably related to issue \\#6993", self, other);
|
||||
}
|
||||
}
|
||||
fn ne(&self, other: &Ident) -> bool {
|
||||
! self.eq(other)
|
||||
}
|
||||
}
|
||||
|
||||
/// A SyntaxContext represents a chain of macro-expandings
|
||||
@ -166,12 +159,15 @@ pub const ILLEGAL_CTXT : SyntaxContext = 1;
|
||||
RustcEncodable, RustcDecodable, Clone, Copy)]
|
||||
pub struct Name(pub u32);
|
||||
|
||||
impl<T: AsRef<str>> PartialEq<T> for Name {
|
||||
fn eq(&self, other: &T) -> bool {
|
||||
self.as_str() == other.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl Name {
|
||||
pub fn as_str<'a>(&'a self) -> &'a str {
|
||||
unsafe {
|
||||
// FIXME #12938: can't use copy_lifetime since &str isn't a &T
|
||||
::std::mem::transmute::<&str,&str>(&token::get_name(*self))
|
||||
}
|
||||
pub fn as_str(&self) -> token::InternedString {
|
||||
token::InternedString::new_from_name(*self)
|
||||
}
|
||||
|
||||
pub fn usize(&self) -> usize {
|
||||
@ -189,7 +185,7 @@ pub type Mrk = u32;
|
||||
|
||||
impl Encodable for Ident {
|
||||
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
s.emit_str(&token::get_ident(*self))
|
||||
s.emit_str(&self.name.as_str())
|
||||
}
|
||||
}
|
||||
|
||||
@ -1073,7 +1069,7 @@ impl TokenTree {
|
||||
pub fn len(&self) -> usize {
|
||||
match *self {
|
||||
TtToken(_, token::DocComment(name)) => {
|
||||
match doc_comment_style(name.as_str()) {
|
||||
match doc_comment_style(&name.as_str()) {
|
||||
AttrOuter => 2,
|
||||
AttrInner => 3
|
||||
}
|
||||
@ -1096,11 +1092,11 @@ impl TokenTree {
|
||||
TtToken(sp, token::Pound)
|
||||
}
|
||||
(&TtToken(sp, token::DocComment(name)), 1)
|
||||
if doc_comment_style(name.as_str()) == AttrInner => {
|
||||
if doc_comment_style(&name.as_str()) == AttrInner => {
|
||||
TtToken(sp, token::Not)
|
||||
}
|
||||
(&TtToken(sp, token::DocComment(name)), _) => {
|
||||
let stripped = strip_doc_comment_decoration(name.as_str());
|
||||
let stripped = strip_doc_comment_decoration(&name.as_str());
|
||||
TtDelimited(sp, Rc::new(Delimited {
|
||||
delim: token::Bracket,
|
||||
open_span: sp,
|
||||
|
@ -25,9 +25,7 @@ use std::u32;
|
||||
|
||||
pub fn path_name_i(idents: &[Ident]) -> String {
|
||||
// FIXME: Bad copies (#2543 -- same for everything else that says "bad")
|
||||
idents.iter().map(|i| {
|
||||
token::get_ident(*i).to_string()
|
||||
}).collect::<Vec<String>>().join("::")
|
||||
idents.iter().map(|i| i.to_string()).collect::<Vec<String>>().join("::")
|
||||
}
|
||||
|
||||
pub fn local_def(id: NodeId) -> DefId {
|
||||
|
@ -63,7 +63,7 @@ pub fn expand_diagnostic_used<'cx>(ecx: &'cx mut ExtCtxt,
|
||||
// Previously used errors.
|
||||
Some(&mut ErrorInfo { description: _, use_site: Some(previous_span) }) => {
|
||||
ecx.span_warn(span, &format!(
|
||||
"diagnostic code {} already used", &token::get_ident(code)
|
||||
"diagnostic code {} already used", code
|
||||
));
|
||||
ecx.span_note(previous_span, "previous invocation");
|
||||
}
|
||||
@ -74,7 +74,7 @@ pub fn expand_diagnostic_used<'cx>(ecx: &'cx mut ExtCtxt,
|
||||
// Unregistered errors.
|
||||
None => {
|
||||
ecx.span_err(span, &format!(
|
||||
"used diagnostic code {} not registered", &token::get_ident(code)
|
||||
"used diagnostic code {} not registered", code
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -110,7 +110,7 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
|
||||
if !msg.starts_with("\n") || !msg.ends_with("\n") {
|
||||
ecx.span_err(span, &format!(
|
||||
"description for error code {} doesn't start and end with a newline",
|
||||
token::get_ident(*code)
|
||||
code
|
||||
));
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
|
||||
ecx.span_err(span, &format!(
|
||||
"description for error code {} contains a line longer than {} characters.\n\
|
||||
if you're inserting a long URL use the footnote style to bypass this check.",
|
||||
token::get_ident(*code), MAX_DESCRIPTION_WIDTH
|
||||
code, MAX_DESCRIPTION_WIDTH
|
||||
));
|
||||
}
|
||||
});
|
||||
@ -134,12 +134,12 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
|
||||
};
|
||||
if diagnostics.insert(code.name, info).is_some() {
|
||||
ecx.span_err(span, &format!(
|
||||
"diagnostic code {} already registered", &token::get_ident(*code)
|
||||
"diagnostic code {} already registered", code
|
||||
));
|
||||
}
|
||||
});
|
||||
let sym = Ident::new(token::gensym(&(
|
||||
"__register_diagnostic_".to_string() + &token::get_ident(*code)
|
||||
let sym = Ident::new(token::gensym(&format!(
|
||||
"__register_diagnostic_{}", code
|
||||
)));
|
||||
MacEager::items(SmallVector::many(vec![
|
||||
ecx.item_mod(
|
||||
@ -163,7 +163,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
|
||||
&ast::TtToken(_, token::Ident(ref crate_name, _)),
|
||||
// DIAGNOSTICS ident.
|
||||
&ast::TtToken(_, token::Ident(ref name, _))
|
||||
) => (crate_name.as_str(), name),
|
||||
) => (*&crate_name, name),
|
||||
_ => unreachable!()
|
||||
};
|
||||
|
||||
@ -172,7 +172,10 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
|
||||
.ok().expect("unable to determine target arch from $CFG_COMPILER_HOST_TRIPLE");
|
||||
|
||||
with_registered_diagnostics(|diagnostics| {
|
||||
if let Err(e) = output_metadata(ecx, &target_triple, crate_name, &diagnostics) {
|
||||
if let Err(e) = output_metadata(ecx,
|
||||
&target_triple,
|
||||
&crate_name.name.as_str(),
|
||||
&diagnostics) {
|
||||
ecx.span_bug(span, &format!(
|
||||
"error writing metadata for triple `{}` and crate `{}`, error: {}, cause: {:?}",
|
||||
target_triple, crate_name, e.description(), e.cause()
|
||||
@ -187,8 +190,8 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
|
||||
diagnostics.iter().filter_map(|(code, info)| {
|
||||
info.description.map(|description| {
|
||||
ecx.expr_tuple(span, vec![
|
||||
ecx.expr_str(span, token::get_name(*code)),
|
||||
ecx.expr_str(span, token::get_name(description))
|
||||
ecx.expr_str(span, code.as_str()),
|
||||
ecx.expr_str(span, description.as_str())
|
||||
])
|
||||
})
|
||||
}).collect();
|
||||
|
@ -629,9 +629,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
}
|
||||
|
||||
fn expr_field_access(&self, sp: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr> {
|
||||
let field_name = token::get_ident(ident);
|
||||
let field_span = Span {
|
||||
lo: sp.lo - Pos::from_usize(field_name.len()),
|
||||
lo: sp.lo - Pos::from_usize(ident.name.as_str().len()),
|
||||
hi: sp.hi,
|
||||
expn_id: sp.expn_id,
|
||||
};
|
||||
|
@ -40,7 +40,7 @@ pub fn expand_syntax_ext<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]
|
||||
} else {
|
||||
match *e {
|
||||
ast::TtToken(_, token::Ident(ident, _)) => {
|
||||
res_str.push_str(&token::get_ident(ident))
|
||||
res_str.push_str(&ident.name.as_str())
|
||||
},
|
||||
_ => {
|
||||
cx.span_err(sp, "concat_idents! requires ident args.");
|
||||
@ -49,7 +49,7 @@ pub fn expand_syntax_ext<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]
|
||||
}
|
||||
}
|
||||
}
|
||||
let res = str_to_ident(&res_str[..]);
|
||||
let res = str_to_ident(&res_str);
|
||||
|
||||
let e = P(ast::Expr {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
|
@ -128,7 +128,7 @@ fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
||||
decoder,
|
||||
cx.ident_of("read_struct"),
|
||||
vec!(
|
||||
cx.expr_str(trait_span, token::get_ident(substr.type_ident)),
|
||||
cx.expr_str(trait_span, substr.type_ident.name.as_str()),
|
||||
cx.expr_usize(trait_span, nfields),
|
||||
cx.lambda_expr_1(trait_span, result, blkarg)
|
||||
))
|
||||
@ -140,10 +140,10 @@ fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
||||
let mut variants = Vec::new();
|
||||
let rvariant_arg = cx.ident_of("read_enum_variant_arg");
|
||||
|
||||
for (i, &(name, v_span, ref parts)) in fields.iter().enumerate() {
|
||||
variants.push(cx.expr_str(v_span, token::get_ident(name)));
|
||||
for (i, &(ident, v_span, ref parts)) in fields.iter().enumerate() {
|
||||
variants.push(cx.expr_str(v_span, ident.name.as_str()));
|
||||
|
||||
let path = cx.path(trait_span, vec![substr.type_ident, name]);
|
||||
let path = cx.path(trait_span, vec![substr.type_ident, ident]);
|
||||
let decoded = decode_static_fields(cx,
|
||||
v_span,
|
||||
path,
|
||||
@ -175,7 +175,7 @@ fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
||||
decoder,
|
||||
cx.ident_of("read_enum"),
|
||||
vec!(
|
||||
cx.expr_str(trait_span, token::get_ident(substr.type_ident)),
|
||||
cx.expr_str(trait_span, substr.type_ident.name.as_str()),
|
||||
cx.lambda_expr_1(trait_span, result, blkarg)
|
||||
))
|
||||
}
|
||||
@ -211,9 +211,9 @@ fn decode_static_fields<F>(cx: &mut ExtCtxt,
|
||||
}
|
||||
Named(ref fields) => {
|
||||
// use the field's span to get nicer error messages.
|
||||
let fields = fields.iter().enumerate().map(|(i, &(name, span))| {
|
||||
let arg = getarg(cx, span, token::get_ident(name), i);
|
||||
cx.field_imm(span, name, arg)
|
||||
let fields = fields.iter().enumerate().map(|(i, &(ident, span))| {
|
||||
let arg = getarg(cx, span, ident.name.as_str(), i);
|
||||
cx.field_imm(span, ident, arg)
|
||||
}).collect();
|
||||
cx.expr_struct(trait_span, outer_pat_path, fields)
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
||||
..
|
||||
}) in fields.iter().enumerate() {
|
||||
let name = match name {
|
||||
Some(id) => token::get_ident(id),
|
||||
Some(id) => id.name.as_str(),
|
||||
None => {
|
||||
token::intern_and_get_ident(&format!("_field{}", i))
|
||||
}
|
||||
@ -223,7 +223,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
||||
encoder,
|
||||
cx.ident_of("emit_struct"),
|
||||
vec!(
|
||||
cx.expr_str(trait_span, token::get_ident(substr.type_ident)),
|
||||
cx.expr_str(trait_span, substr.type_ident.name.as_str()),
|
||||
cx.expr_usize(trait_span, fields.len()),
|
||||
blk
|
||||
))
|
||||
@ -263,7 +263,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
||||
}
|
||||
|
||||
let blk = cx.lambda_stmts_1(trait_span, stmts, blkarg);
|
||||
let name = cx.expr_str(trait_span, token::get_ident(variant.node.name));
|
||||
let name = cx.expr_str(trait_span, variant.node.name.name.as_str());
|
||||
let call = cx.expr_method_call(trait_span, blkencoder,
|
||||
cx.ident_of("emit_enum_variant"),
|
||||
vec!(name,
|
||||
@ -275,7 +275,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
||||
encoder,
|
||||
cx.ident_of("emit_enum"),
|
||||
vec!(
|
||||
cx.expr_str(trait_span, token::get_ident(substr.type_ident)),
|
||||
cx.expr_str(trait_span, substr.type_ident.name.as_str()),
|
||||
blk
|
||||
));
|
||||
cx.expr_block(cx.block(trait_span, vec!(me), Some(ret)))
|
||||
|
@ -59,7 +59,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
|
||||
// build fmt.debug_struct(<name>).field(<fieldname>, &<fieldval>)....build()
|
||||
// or fmt.debug_tuple(<name>).field(&<fieldval>)....build()
|
||||
// based on the "shape".
|
||||
let name = match *substr.fields {
|
||||
let ident = match *substr.fields {
|
||||
Struct(_) => substr.type_ident,
|
||||
EnumMatching(_, v, _) => v.node.name,
|
||||
EnumNonMatchingCollapsed(..) | StaticStruct(..) | StaticEnum(..) => {
|
||||
@ -69,7 +69,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
|
||||
|
||||
// We want to make sure we have the expn_id set so that we can use unstable methods
|
||||
let span = Span { expn_id: cx.backtrace(), .. span };
|
||||
let name = cx.expr_lit(span, ast::Lit_::LitStr(token::get_ident(name),
|
||||
let name = cx.expr_lit(span, ast::Lit_::LitStr(ident.name.as_str(),
|
||||
ast::StrStyle::CookedStr));
|
||||
let mut expr = substr.nonself_args[0].clone();
|
||||
|
||||
@ -102,7 +102,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
|
||||
|
||||
for field in fields {
|
||||
let name = cx.expr_lit(field.span, ast::Lit_::LitStr(
|
||||
token::get_ident(field.name.clone().unwrap()),
|
||||
field.name.unwrap().name.as_str(),
|
||||
ast::StrStyle::CookedStr));
|
||||
|
||||
// Use double indirection to make sure this works for unsized types
|
||||
|
@ -545,14 +545,13 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac,
|
||||
// let compilation continue
|
||||
return None;
|
||||
}
|
||||
let extname = pth.segments[0].identifier;
|
||||
let extnamestr = token::get_ident(extname);
|
||||
match fld.cx.syntax_env.find(&extname.name) {
|
||||
let extname = pth.segments[0].identifier.name;
|
||||
match fld.cx.syntax_env.find(&extname) {
|
||||
None => {
|
||||
fld.cx.span_err(
|
||||
pth.span,
|
||||
&format!("macro undefined: '{}!'",
|
||||
&extnamestr));
|
||||
&extname));
|
||||
|
||||
// let compilation continue
|
||||
None
|
||||
@ -562,7 +561,7 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac,
|
||||
fld.cx.bt_push(ExpnInfo {
|
||||
call_site: span,
|
||||
callee: NameAndSpan {
|
||||
name: extnamestr.to_string(),
|
||||
name: extname.to_string(),
|
||||
format: MacroBang,
|
||||
span: exp_span,
|
||||
allow_internal_unstable: allow_internal_unstable,
|
||||
@ -589,7 +588,7 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac,
|
||||
fld.cx.span_err(
|
||||
pth.span,
|
||||
&format!("non-expression macro in expression position: {}",
|
||||
&extnamestr[..]
|
||||
extname
|
||||
));
|
||||
return None;
|
||||
}
|
||||
@ -600,7 +599,7 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac,
|
||||
fld.cx.span_err(
|
||||
pth.span,
|
||||
&format!("'{}' is not a tt-style macro",
|
||||
&extnamestr));
|
||||
extname));
|
||||
None
|
||||
}
|
||||
}
|
||||
@ -712,19 +711,18 @@ pub fn expand_item_mac(it: P<ast::Item>,
|
||||
node: MacInvocTT(ref pth, ref tts, _),
|
||||
..
|
||||
}) => {
|
||||
(pth.segments[0].identifier, pth.span, (*tts).clone())
|
||||
(pth.segments[0].identifier.name, pth.span, (*tts).clone())
|
||||
}
|
||||
_ => fld.cx.span_bug(it.span, "invalid item macro invocation")
|
||||
};
|
||||
|
||||
let extnamestr = token::get_ident(extname);
|
||||
let fm = fresh_mark();
|
||||
let items = {
|
||||
let expanded = match fld.cx.syntax_env.find(&extname.name) {
|
||||
let expanded = match fld.cx.syntax_env.find(&extname) {
|
||||
None => {
|
||||
fld.cx.span_err(path_span,
|
||||
&format!("macro undefined: '{}!'",
|
||||
extnamestr));
|
||||
extname));
|
||||
// let compilation continue
|
||||
return SmallVector::zero();
|
||||
}
|
||||
@ -735,14 +733,14 @@ pub fn expand_item_mac(it: P<ast::Item>,
|
||||
fld.cx
|
||||
.span_err(path_span,
|
||||
&format!("macro {}! expects no ident argument, given '{}'",
|
||||
extnamestr,
|
||||
token::get_ident(it.ident)));
|
||||
extname,
|
||||
it.ident));
|
||||
return SmallVector::zero();
|
||||
}
|
||||
fld.cx.bt_push(ExpnInfo {
|
||||
call_site: it.span,
|
||||
callee: NameAndSpan {
|
||||
name: extnamestr.to_string(),
|
||||
name: extname.to_string(),
|
||||
format: MacroBang,
|
||||
span: span,
|
||||
allow_internal_unstable: allow_internal_unstable,
|
||||
@ -756,13 +754,13 @@ pub fn expand_item_mac(it: P<ast::Item>,
|
||||
if it.ident.name == parse::token::special_idents::invalid.name {
|
||||
fld.cx.span_err(path_span,
|
||||
&format!("macro {}! expects an ident argument",
|
||||
&extnamestr));
|
||||
extname));
|
||||
return SmallVector::zero();
|
||||
}
|
||||
fld.cx.bt_push(ExpnInfo {
|
||||
call_site: it.span,
|
||||
callee: NameAndSpan {
|
||||
name: extnamestr.to_string(),
|
||||
name: extname.to_string(),
|
||||
format: MacroBang,
|
||||
span: span,
|
||||
allow_internal_unstable: allow_internal_unstable,
|
||||
@ -783,7 +781,7 @@ pub fn expand_item_mac(it: P<ast::Item>,
|
||||
fld.cx.bt_push(ExpnInfo {
|
||||
call_site: it.span,
|
||||
callee: NameAndSpan {
|
||||
name: extnamestr.to_string(),
|
||||
name: extname.to_string(),
|
||||
format: MacroBang,
|
||||
span: None,
|
||||
// `macro_rules!` doesn't directly allow
|
||||
@ -828,7 +826,7 @@ pub fn expand_item_mac(it: P<ast::Item>,
|
||||
_ => {
|
||||
fld.cx.span_err(it.span,
|
||||
&format!("{}! is not legal in item position",
|
||||
&extnamestr));
|
||||
extname));
|
||||
return SmallVector::zero();
|
||||
}
|
||||
}
|
||||
@ -847,7 +845,7 @@ pub fn expand_item_mac(it: P<ast::Item>,
|
||||
None => {
|
||||
fld.cx.span_err(path_span,
|
||||
&format!("non-item macro in item position: {}",
|
||||
&extnamestr));
|
||||
extname));
|
||||
return SmallVector::zero();
|
||||
}
|
||||
};
|
||||
@ -1096,13 +1094,12 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
|
||||
fld.cx.span_err(pth.span, "expected macro name without module separators");
|
||||
return DummyResult::raw_pat(span);
|
||||
}
|
||||
let extname = pth.segments[0].identifier;
|
||||
let extnamestr = token::get_ident(extname);
|
||||
let marked_after = match fld.cx.syntax_env.find(&extname.name) {
|
||||
let extname = pth.segments[0].identifier.name;
|
||||
let marked_after = match fld.cx.syntax_env.find(&extname) {
|
||||
None => {
|
||||
fld.cx.span_err(pth.span,
|
||||
&format!("macro undefined: '{}!'",
|
||||
extnamestr));
|
||||
extname));
|
||||
// let compilation continue
|
||||
return DummyResult::raw_pat(span);
|
||||
}
|
||||
@ -1112,7 +1109,7 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
|
||||
fld.cx.bt_push(ExpnInfo {
|
||||
call_site: span,
|
||||
callee: NameAndSpan {
|
||||
name: extnamestr.to_string(),
|
||||
name: extname.to_string(),
|
||||
format: MacroBang,
|
||||
span: tt_span,
|
||||
allow_internal_unstable: allow_internal_unstable,
|
||||
@ -1132,7 +1129,7 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
|
||||
pth.span,
|
||||
&format!(
|
||||
"non-pattern macro in pattern position: {}",
|
||||
&extnamestr
|
||||
extname
|
||||
)
|
||||
);
|
||||
return DummyResult::raw_pat(span);
|
||||
@ -1145,7 +1142,7 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
|
||||
_ => {
|
||||
fld.cx.span_err(span,
|
||||
&format!("{}! is not legal in pattern position",
|
||||
&extnamestr));
|
||||
extname));
|
||||
return DummyResult::raw_pat(span);
|
||||
}
|
||||
}
|
||||
@ -2121,8 +2118,7 @@ mod tests {
|
||||
= varref.segments.iter().map(|s| s.identifier)
|
||||
.collect();
|
||||
println!("varref #{}: {:?}, resolves to {}",idx, varref_idents, varref_name);
|
||||
let string = token::get_ident(final_varref_ident);
|
||||
println!("varref's first segment's string: \"{}\"", &string[..]);
|
||||
println!("varref's first segment's string: \"{}\"", final_varref_ident);
|
||||
println!("binding #{}: {}, resolves to {}",
|
||||
binding_idx, bindings[binding_idx], binding_name);
|
||||
mtwt::with_sctable(|x| mtwt::display_sctable(x));
|
||||
@ -2174,11 +2170,7 @@ foo_module!();
|
||||
// find the xx binding
|
||||
let bindings = crate_bindings(&cr);
|
||||
let cxbinds: Vec<&ast::Ident> =
|
||||
bindings.iter().filter(|b| {
|
||||
let ident = token::get_ident(**b);
|
||||
let string = &ident[..];
|
||||
"xx" == string
|
||||
}).collect();
|
||||
bindings.iter().filter(|b| b.name == "xx").collect();
|
||||
let cxbinds: &[&ast::Ident] = &cxbinds[..];
|
||||
let cxbind = match (cxbinds.len(), cxbinds.get(0)) {
|
||||
(1, Some(b)) => *b,
|
||||
@ -2190,7 +2182,7 @@ foo_module!();
|
||||
// the xx binding should bind all of the xx varrefs:
|
||||
for (idx,v) in varrefs.iter().filter(|p| {
|
||||
p.segments.len() == 1
|
||||
&& "xx" == &*token::get_ident(p.segments[0].identifier)
|
||||
&& p.segments[0].identifier.name == "xx"
|
||||
}).enumerate() {
|
||||
if mtwt::resolve(v.segments[0].identifier) != resolved_binding {
|
||||
println!("uh oh, xx binding didn't match xx varref:");
|
||||
|
@ -121,8 +121,7 @@ fn parse_args(ecx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let interned_name = token::get_ident(ident);
|
||||
let name = &interned_name[..];
|
||||
let name: &str = &ident.name.as_str();
|
||||
|
||||
panictry!(p.expect(&token::Eq));
|
||||
let e = p.parse_expr();
|
||||
|
@ -407,7 +407,7 @@ fn id_ext(str: &str) -> ast::Ident {
|
||||
|
||||
// Lift an ident to the expr that evaluates to that ident.
|
||||
fn mk_ident(cx: &ExtCtxt, sp: Span, ident: ast::Ident) -> P<ast::Expr> {
|
||||
let e_str = cx.expr_str(sp, token::get_ident(ident));
|
||||
let e_str = cx.expr_str(sp, ident.name.as_str());
|
||||
cx.expr_method_call(sp,
|
||||
cx.expr_ident(sp, id_ext("ext_cx")),
|
||||
id_ext("ident_of"),
|
||||
@ -416,7 +416,7 @@ fn mk_ident(cx: &ExtCtxt, sp: Span, ident: ast::Ident) -> P<ast::Expr> {
|
||||
|
||||
// Lift a name to the expr that evaluates to that name
|
||||
fn mk_name(cx: &ExtCtxt, sp: Span, ident: ast::Ident) -> P<ast::Expr> {
|
||||
let e_str = cx.expr_str(sp, token::get_ident(ident));
|
||||
let e_str = cx.expr_str(sp, ident.name.as_str());
|
||||
cx.expr_method_call(sp,
|
||||
cx.expr_ident(sp, id_ext("ext_cx")),
|
||||
id_ext("name_of"),
|
||||
|
@ -76,7 +76,7 @@ pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
||||
base::check_zero_tts(cx, sp, tts, "module_path!");
|
||||
let string = cx.mod_path()
|
||||
.iter()
|
||||
.map(|x| token::get_ident(*x).to_string())
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join("::");
|
||||
base::MacEager::expr(cx.expr_str(
|
||||
|
@ -223,11 +223,10 @@ pub fn nameize(p_s: &ParseSess, ms: &[TokenTree], res: &[Rc<NamedMatch>])
|
||||
*idx += 1;
|
||||
}
|
||||
Occupied(..) => {
|
||||
let string = token::get_ident(bind_name);
|
||||
panic!(p_s.span_diagnostic
|
||||
.span_fatal(sp,
|
||||
&format!("duplicated bind name: {}",
|
||||
&string)))
|
||||
bind_name)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -460,9 +459,7 @@ pub fn parse(sess: &ParseSess,
|
||||
let nts = bb_eis.iter().map(|ei| {
|
||||
match ei.top_elts.get_tt(ei.idx) {
|
||||
TtToken(_, MatchNt(bind, name, _, _)) => {
|
||||
(format!("{} ('{}')",
|
||||
token::get_ident(name),
|
||||
token::get_ident(bind))).to_string()
|
||||
format!("{} ('{}')", name, bind)
|
||||
}
|
||||
_ => panic!()
|
||||
} }).collect::<Vec<String>>().join(" or ");
|
||||
@ -484,11 +481,10 @@ pub fn parse(sess: &ParseSess,
|
||||
|
||||
let mut ei = bb_eis.pop().unwrap();
|
||||
match ei.top_elts.get_tt(ei.idx) {
|
||||
TtToken(span, MatchNt(_, name, _, _)) => {
|
||||
let name_string = token::get_ident(name);
|
||||
TtToken(span, MatchNt(_, ident, _, _)) => {
|
||||
let match_cur = ei.match_cur;
|
||||
(&mut ei.matches[match_cur]).push(Rc::new(MatchedNonterminal(
|
||||
parse_nt(&mut rust_parser, span, &name_string))));
|
||||
parse_nt(&mut rust_parser, span, &ident.name.as_str()))));
|
||||
ei.idx += 1;
|
||||
ei.match_cur += 1;
|
||||
}
|
||||
|
@ -56,10 +56,9 @@ impl<'a> ParserAnyMacro<'a> {
|
||||
let span = parser.span;
|
||||
parser.span_err(span, &msg[..]);
|
||||
|
||||
let name = token::get_ident(self.macro_ident);
|
||||
let msg = format!("caused by the macro expansion here; the usage \
|
||||
of `{}` is likely invalid in this context",
|
||||
name);
|
||||
self.macro_ident);
|
||||
parser.span_note(self.site_span, &msg[..]);
|
||||
}
|
||||
}
|
||||
@ -154,7 +153,7 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt,
|
||||
-> Box<MacResult+'cx> {
|
||||
if cx.trace_macros() {
|
||||
println!("{}! {{ {} }}",
|
||||
token::get_ident(name),
|
||||
name,
|
||||
print::pprust::tts_to_string(arg));
|
||||
}
|
||||
|
||||
@ -326,7 +325,7 @@ fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token)
|
||||
TtToken(sp, MatchNt(ref name, ref frag_spec, _, _)) => {
|
||||
// ii. If T is a simple NT, look ahead to the next token T' in
|
||||
// M. If T' is in the set FOLLOW(NT), continue. Else; reject.
|
||||
if can_be_followed_by_any(frag_spec.as_str()) {
|
||||
if can_be_followed_by_any(&frag_spec.name.as_str()) {
|
||||
continue
|
||||
} else {
|
||||
let next_token = match tokens.peek() {
|
||||
@ -340,13 +339,13 @@ fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token)
|
||||
// possibility that the sequence occurred
|
||||
// zero times (in which case we need to
|
||||
// look at the token that follows the
|
||||
// sequence, which may itself a sequence,
|
||||
// sequence, which may itself be a sequence,
|
||||
// and so on).
|
||||
cx.span_err(sp,
|
||||
&format!("`${0}:{1}` is followed by a \
|
||||
sequence repetition, which is not \
|
||||
allowed for `{1}` fragments",
|
||||
name.as_str(), frag_spec.as_str())
|
||||
name, frag_spec)
|
||||
);
|
||||
Eof
|
||||
},
|
||||
@ -359,7 +358,7 @@ fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token)
|
||||
let tok = if let TtToken(_, ref tok) = *token { tok } else { unreachable!() };
|
||||
|
||||
// If T' is in the set FOLLOW(NT), continue. Else, reject.
|
||||
match (&next_token, is_in_follow(cx, &next_token, frag_spec.as_str())) {
|
||||
match (&next_token, is_in_follow(cx, &next_token, &frag_spec.name.as_str())) {
|
||||
(_, Err(msg)) => {
|
||||
cx.span_err(sp, &msg);
|
||||
continue
|
||||
@ -369,7 +368,7 @@ fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token)
|
||||
(next, Ok(false)) => {
|
||||
cx.span_err(sp, &format!("`${0}:{1}` is followed by `{2}`, which \
|
||||
is not allowed for `{1}` fragments",
|
||||
name.as_str(), frag_spec.as_str(),
|
||||
name, frag_spec,
|
||||
token_to_string(next)));
|
||||
continue
|
||||
},
|
||||
@ -495,14 +494,14 @@ fn is_in_follow(_: &ExtCtxt, tok: &Token, frag: &str) -> Result<bool, String> {
|
||||
"pat" => {
|
||||
match *tok {
|
||||
FatArrow | Comma | Eq => Ok(true),
|
||||
Ident(i, _) if i.as_str() == "if" || i.as_str() == "in" => Ok(true),
|
||||
Ident(i, _) if i.name == "if" || i.name == "in" => Ok(true),
|
||||
_ => Ok(false)
|
||||
}
|
||||
},
|
||||
"path" | "ty" => {
|
||||
match *tok {
|
||||
Comma | FatArrow | Colon | Eq | Gt | Semi => Ok(true),
|
||||
Ident(i, _) if i.as_str() == "as" => Ok(true),
|
||||
Ident(i, _) if i.name == "as" => Ok(true),
|
||||
_ => Ok(false)
|
||||
}
|
||||
},
|
||||
|
@ -140,11 +140,9 @@ impl Add for LockstepIterSize {
|
||||
LisContradiction(_) => other,
|
||||
LisConstraint(r_len, _) if l_len == r_len => self.clone(),
|
||||
LisConstraint(r_len, r_id) => {
|
||||
let l_n = token::get_ident(l_id.clone());
|
||||
let r_n = token::get_ident(r_id);
|
||||
LisContradiction(format!("inconsistent lockstep iteration: \
|
||||
'{:?}' has {} items, but '{:?}' has {}",
|
||||
l_n, l_len, r_n, r_len).to_string())
|
||||
'{}' has {} items, but '{}' has {}",
|
||||
l_id, l_len, r_id, r_len))
|
||||
}
|
||||
},
|
||||
}
|
||||
@ -308,8 +306,8 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
|
||||
MatchedSeq(..) => {
|
||||
panic!(r.sp_diag.span_fatal(
|
||||
r.cur_span, /* blame the macro writer */
|
||||
&format!("variable '{:?}' is still repeating at this depth",
|
||||
token::get_ident(ident))));
|
||||
&format!("variable '{}' is still repeating at this depth",
|
||||
ident)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -582,7 +582,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
||||
}
|
||||
|
||||
fn visit_name(&mut self, sp: Span, name: ast::Name) {
|
||||
if !token::get_name(name).is_ascii() {
|
||||
if !name.as_str().is_ascii() {
|
||||
self.gate_feature("non_ascii_idents", sp,
|
||||
"non-ascii idents are not fully supported.");
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ use codemap::{self, Span, CodeMap, FileMap};
|
||||
use diagnostic::{SpanHandler, Handler, Auto, FatalError};
|
||||
use parse::attr::ParserAttr;
|
||||
use parse::parser::Parser;
|
||||
use parse::token::InternedString;
|
||||
use ptr::P;
|
||||
use str::char_at;
|
||||
|
||||
@ -439,7 +440,7 @@ fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool {
|
||||
fn filtered_float_lit(data: token::InternedString, suffix: Option<&str>,
|
||||
sd: &SpanHandler, sp: Span) -> ast::Lit_ {
|
||||
debug!("filtered_float_lit: {}, {:?}", data, suffix);
|
||||
match suffix {
|
||||
match suffix.as_ref().map(|s| &**s) {
|
||||
Some("f32") => ast::LitFloat(data, ast::TyF32),
|
||||
Some("f64") => ast::LitFloat(data, ast::TyF64),
|
||||
Some(suf) => {
|
||||
@ -457,12 +458,13 @@ fn filtered_float_lit(data: token::InternedString, suffix: Option<&str>,
|
||||
None => ast::LitFloatUnsuffixed(data)
|
||||
}
|
||||
}
|
||||
pub fn float_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) -> ast::Lit_ {
|
||||
pub fn float_lit(s: &str, suffix: Option<InternedString>,
|
||||
sd: &SpanHandler, sp: Span) -> ast::Lit_ {
|
||||
debug!("float_lit: {:?}, {:?}", s, suffix);
|
||||
// FIXME #2252: bounds checking float literals is deferred until trans
|
||||
let s = s.chars().filter(|&c| c != '_').collect::<String>();
|
||||
let data = token::intern_and_get_ident(&*s);
|
||||
filtered_float_lit(data, suffix, sd, sp)
|
||||
let data = token::intern_and_get_ident(&s);
|
||||
filtered_float_lit(data, suffix.as_ref().map(|s| &**s), sd, sp)
|
||||
}
|
||||
|
||||
/// Parse a string representing a byte literal into its final form. Similar to `char_lit`
|
||||
@ -557,7 +559,11 @@ pub fn binary_lit(lit: &str) -> Rc<Vec<u8>> {
|
||||
Rc::new(res)
|
||||
}
|
||||
|
||||
pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) -> ast::Lit_ {
|
||||
pub fn integer_lit(s: &str,
|
||||
suffix: Option<InternedString>,
|
||||
sd: &SpanHandler,
|
||||
sp: Span)
|
||||
-> ast::Lit_ {
|
||||
// s can only be ascii, byte indexing is fine
|
||||
|
||||
let s2 = s.chars().filter(|&c| c != '_').collect::<String>();
|
||||
@ -579,8 +585,8 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) ->
|
||||
}
|
||||
|
||||
// 1f64 and 2f32 etc. are valid float literals.
|
||||
match suffix {
|
||||
Some(suf) if looks_like_width_suffix(&['f'], suf) => {
|
||||
if let Some(ref suf) = suffix {
|
||||
if looks_like_width_suffix(&['f'], suf) {
|
||||
match base {
|
||||
16 => sd.span_err(sp, "hexadecimal float literal is not supported"),
|
||||
8 => sd.span_err(sp, "octal float literal is not supported"),
|
||||
@ -588,18 +594,17 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) ->
|
||||
_ => ()
|
||||
}
|
||||
let ident = token::intern_and_get_ident(&*s);
|
||||
return filtered_float_lit(ident, suffix, sd, sp)
|
||||
return filtered_float_lit(ident, Some(&**suf), sd, sp)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if base != 10 {
|
||||
s = &s[2..];
|
||||
}
|
||||
|
||||
if let Some(suf) = suffix {
|
||||
if let Some(ref suf) = suffix {
|
||||
if suf.is_empty() { sd.span_bug(sp, "found empty literal suffix in Some")}
|
||||
ty = match suf {
|
||||
ty = match &**suf {
|
||||
"isize" => ast::SignedIntLit(ast::TyIs, ast::Plus),
|
||||
"i8" => ast::SignedIntLit(ast::TyI8, ast::Plus),
|
||||
"i16" => ast::SignedIntLit(ast::TyI16, ast::Plus),
|
||||
@ -739,8 +744,8 @@ mod tests {
|
||||
Some(&ast::TtToken(_, token::Ident(name_zip, token::Plain))),
|
||||
Some(&ast::TtDelimited(_, ref macro_delimed)),
|
||||
)
|
||||
if name_macro_rules.as_str() == "macro_rules"
|
||||
&& name_zip.as_str() == "zip" => {
|
||||
if name_macro_rules.name == "macro_rules"
|
||||
&& name_zip.name == "zip" => {
|
||||
let tts = ¯o_delimed.tts[..];
|
||||
match (tts.len(), tts.get(0), tts.get(1), tts.get(2)) {
|
||||
(
|
||||
@ -755,10 +760,10 @@ mod tests {
|
||||
(
|
||||
2,
|
||||
Some(&ast::TtToken(_, token::Dollar)),
|
||||
Some(&ast::TtToken(_, token::Ident(name, token::Plain))),
|
||||
Some(&ast::TtToken(_, token::Ident(ident, token::Plain))),
|
||||
)
|
||||
if first_delimed.delim == token::Paren
|
||||
&& name.as_str() == "a" => {},
|
||||
&& ident.name == "a" => {},
|
||||
_ => panic!("value 3: {:?}", **first_delimed),
|
||||
}
|
||||
let tts = &second_delimed.tts[..];
|
||||
@ -766,10 +771,10 @@ mod tests {
|
||||
(
|
||||
2,
|
||||
Some(&ast::TtToken(_, token::Dollar)),
|
||||
Some(&ast::TtToken(_, token::Ident(name, token::Plain))),
|
||||
Some(&ast::TtToken(_, token::Ident(ident, token::Plain))),
|
||||
)
|
||||
if second_delimed.delim == token::Paren
|
||||
&& name.as_str() == "a" => {},
|
||||
&& ident.name == "a" => {},
|
||||
_ => panic!("value 4: {:?}", **second_delimed),
|
||||
}
|
||||
},
|
||||
|
@ -92,10 +92,8 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
|
||||
|
||||
fn is_obsolete_ident(&mut self, ident: &str) -> bool {
|
||||
match self.token {
|
||||
token::Ident(sid, _) => {
|
||||
token::get_ident(sid) == ident
|
||||
}
|
||||
_ => false
|
||||
token::Ident(sid, _) => sid.name == ident,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ impl TokenType {
|
||||
match *self {
|
||||
TokenType::Token(ref t) => format!("`{}`", Parser::token_to_string(t)),
|
||||
TokenType::Operator => "an operator".to_string(),
|
||||
TokenType::Keyword(kw) => format!("`{}`", token::get_name(kw.to_name())),
|
||||
TokenType::Keyword(kw) => format!("`{}`", kw.to_name()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1023,7 +1023,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
|
||||
pub fn id_to_interned_str(&mut self, id: Ident) -> InternedString {
|
||||
token::get_ident(id)
|
||||
id.name.as_str()
|
||||
}
|
||||
|
||||
/// Is the current token one of the keywords that signals a bare function
|
||||
@ -1498,20 +1498,20 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
token::Literal(lit, suf) => {
|
||||
let (suffix_illegal, out) = match lit {
|
||||
token::Byte(i) => (true, LitByte(parse::byte_lit(i.as_str()).0)),
|
||||
token::Char(i) => (true, LitChar(parse::char_lit(i.as_str()).0)),
|
||||
token::Byte(i) => (true, LitByte(parse::byte_lit(&i.as_str()).0)),
|
||||
token::Char(i) => (true, LitChar(parse::char_lit(&i.as_str()).0)),
|
||||
|
||||
// there are some valid suffixes for integer and
|
||||
// float literals, so all the handling is done
|
||||
// internally.
|
||||
token::Integer(s) => {
|
||||
(false, parse::integer_lit(s.as_str(),
|
||||
(false, parse::integer_lit(&s.as_str(),
|
||||
suf.as_ref().map(|s| s.as_str()),
|
||||
&self.sess.span_diagnostic,
|
||||
self.last_span))
|
||||
}
|
||||
token::Float(s) => {
|
||||
(false, parse::float_lit(s.as_str(),
|
||||
(false, parse::float_lit(&s.as_str(),
|
||||
suf.as_ref().map(|s| s.as_str()),
|
||||
&self.sess.span_diagnostic,
|
||||
self.last_span))
|
||||
@ -1519,20 +1519,20 @@ impl<'a> Parser<'a> {
|
||||
|
||||
token::Str_(s) => {
|
||||
(true,
|
||||
LitStr(token::intern_and_get_ident(&parse::str_lit(s.as_str())),
|
||||
LitStr(token::intern_and_get_ident(&parse::str_lit(&s.as_str())),
|
||||
ast::CookedStr))
|
||||
}
|
||||
token::StrRaw(s, n) => {
|
||||
(true,
|
||||
LitStr(
|
||||
token::intern_and_get_ident(&parse::raw_str_lit(s.as_str())),
|
||||
token::intern_and_get_ident(&parse::raw_str_lit(&s.as_str())),
|
||||
ast::RawStr(n)))
|
||||
}
|
||||
token::Binary(i) =>
|
||||
(true, LitBinary(parse::binary_lit(i.as_str()))),
|
||||
(true, LitBinary(parse::binary_lit(&i.as_str()))),
|
||||
token::BinaryRaw(i, _) =>
|
||||
(true,
|
||||
LitBinary(Rc::new(i.as_str().as_bytes().iter().cloned().collect()))),
|
||||
LitBinary(Rc::new(i.to_string().into_bytes()))),
|
||||
};
|
||||
|
||||
if suffix_illegal {
|
||||
@ -2448,7 +2448,7 @@ impl<'a> Parser<'a> {
|
||||
match self.token {
|
||||
token::SubstNt(name, _) =>
|
||||
return Err(self.fatal(&format!("unknown macro variable `{}`",
|
||||
token::get_ident(name)))),
|
||||
name))),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@ -4740,7 +4740,7 @@ impl<'a> Parser<'a> {
|
||||
if fields.is_empty() {
|
||||
return Err(self.fatal(&format!("unit-like struct definition should be \
|
||||
written as `struct {};`",
|
||||
token::get_ident(class_name.clone()))));
|
||||
class_name)));
|
||||
}
|
||||
|
||||
try!(self.bump());
|
||||
@ -4779,7 +4779,7 @@ impl<'a> Parser<'a> {
|
||||
if fields.is_empty() {
|
||||
return Err(self.fatal(&format!("unit-like struct definition should be \
|
||||
written as `struct {};`",
|
||||
token::get_ident(class_name.clone()))));
|
||||
class_name)));
|
||||
}
|
||||
|
||||
generics.where_clause = try!(self.parse_where_clause());
|
||||
@ -4924,8 +4924,7 @@ impl<'a> Parser<'a> {
|
||||
/// Returns either a path to a module, or .
|
||||
pub fn default_submod_path(id: ast::Ident, dir_path: &Path, codemap: &CodeMap) -> ModulePath
|
||||
{
|
||||
let mod_string = token::get_ident(id);
|
||||
let mod_name = mod_string.to_string();
|
||||
let mod_name = id.to_string();
|
||||
let default_path_str = format!("{}.rs", mod_name);
|
||||
let secondary_path_str = format!("{}/mod.rs", mod_name);
|
||||
let default_path = dir_path.join(&default_path_str);
|
||||
@ -5013,7 +5012,7 @@ impl<'a> Parser<'a> {
|
||||
|
||||
self.eval_src_mod_from_path(path,
|
||||
owns_directory,
|
||||
token::get_ident(id).to_string(),
|
||||
id.to_string(),
|
||||
id_sp)
|
||||
}
|
||||
|
||||
@ -5217,7 +5216,7 @@ impl<'a> Parser<'a> {
|
||||
self.span_err(start_span,
|
||||
&format!("unit-like struct variant should be written \
|
||||
without braces, as `{},`",
|
||||
token::get_ident(ident)));
|
||||
ident));
|
||||
}
|
||||
kind = StructVariantKind(struct_def);
|
||||
} else if self.check(&token::OpenDelim(token::Paren)) {
|
||||
@ -5285,8 +5284,7 @@ impl<'a> Parser<'a> {
|
||||
let sp = self.span;
|
||||
self.expect_no_suffix(sp, "ABI spec", suf);
|
||||
try!(self.bump());
|
||||
let the_string = s.as_str();
|
||||
match abi::lookup(the_string) {
|
||||
match abi::lookup(&s.as_str()) {
|
||||
Some(abi) => Ok(Some(abi)),
|
||||
None => {
|
||||
let last_span = self.last_span;
|
||||
@ -5295,7 +5293,7 @@ impl<'a> Parser<'a> {
|
||||
&format!("illegal ABI: expected one of [{}], \
|
||||
found `{}`",
|
||||
abi::all_names().join(", "),
|
||||
the_string));
|
||||
s));
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
@ -647,6 +647,12 @@ impl InternedString {
|
||||
string: string,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn new_from_name(name: ast::Name) -> InternedString {
|
||||
let interner = get_ident_interner();
|
||||
InternedString::new_from_rc_str(interner.get(name))
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for InternedString {
|
||||
@ -678,7 +684,7 @@ impl<'a> PartialEq<&'a str> for InternedString {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PartialEq<InternedString > for &'a str {
|
||||
impl<'a> PartialEq<InternedString> for &'a str {
|
||||
#[inline(always)]
|
||||
fn eq(&self, other: &InternedString) -> bool {
|
||||
PartialEq::eq(*self, &other.string[..])
|
||||
@ -691,7 +697,7 @@ impl<'a> PartialEq<InternedString > for &'a str {
|
||||
|
||||
impl Decodable for InternedString {
|
||||
fn decode<D: Decoder>(d: &mut D) -> Result<InternedString, D::Error> {
|
||||
Ok(get_name(get_ident_interner().intern(&try!(d.read_str())[..])))
|
||||
Ok(intern(try!(d.read_str()).as_ref()).as_str())
|
||||
}
|
||||
}
|
||||
|
||||
@ -701,25 +707,11 @@ impl Encodable for InternedString {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the string contents of a name, using the thread-local interner.
|
||||
#[inline]
|
||||
pub fn get_name(name: ast::Name) -> InternedString {
|
||||
let interner = get_ident_interner();
|
||||
InternedString::new_from_rc_str(interner.get(name))
|
||||
}
|
||||
|
||||
/// Returns the string contents of an identifier, using the thread-local
|
||||
/// interner.
|
||||
#[inline]
|
||||
pub fn get_ident(ident: ast::Ident) -> InternedString {
|
||||
get_name(ident.name)
|
||||
}
|
||||
|
||||
/// Interns and returns the string contents of an identifier, using the
|
||||
/// thread-local interner.
|
||||
#[inline]
|
||||
pub fn intern_and_get_ident(s: &str) -> InternedString {
|
||||
get_name(intern(s))
|
||||
intern(s).as_str()
|
||||
}
|
||||
|
||||
/// Maps a string to its interned representation.
|
||||
|
@ -251,40 +251,40 @@ pub fn token_to_string(tok: &Token) -> String {
|
||||
/* Literals */
|
||||
token::Literal(lit, suf) => {
|
||||
let mut out = match lit {
|
||||
token::Byte(b) => format!("b'{}'", b.as_str()),
|
||||
token::Char(c) => format!("'{}'", c.as_str()),
|
||||
token::Float(c) => c.as_str().to_string(),
|
||||
token::Integer(c) => c.as_str().to_string(),
|
||||
token::Str_(s) => format!("\"{}\"", s.as_str()),
|
||||
token::Byte(b) => format!("b'{}'", b),
|
||||
token::Char(c) => format!("'{}'", c),
|
||||
token::Float(c) => c.to_string(),
|
||||
token::Integer(c) => c.to_string(),
|
||||
token::Str_(s) => format!("\"{}\"", s),
|
||||
token::StrRaw(s, n) => format!("r{delim}\"{string}\"{delim}",
|
||||
delim=repeat("#", n),
|
||||
string=s.as_str()),
|
||||
token::Binary(v) => format!("b\"{}\"", v.as_str()),
|
||||
string=s),
|
||||
token::Binary(v) => format!("b\"{}\"", v),
|
||||
token::BinaryRaw(s, n) => format!("br{delim}\"{string}\"{delim}",
|
||||
delim=repeat("#", n),
|
||||
string=s.as_str()),
|
||||
string=s),
|
||||
};
|
||||
|
||||
if let Some(s) = suf {
|
||||
out.push_str(s.as_str())
|
||||
out.push_str(&s.as_str())
|
||||
}
|
||||
|
||||
out
|
||||
}
|
||||
|
||||
/* Name components */
|
||||
token::Ident(s, _) => token::get_ident(s).to_string(),
|
||||
token::Lifetime(s) => format!("{}", token::get_ident(s)),
|
||||
token::Ident(s, _) => s.to_string(),
|
||||
token::Lifetime(s) => s.to_string(),
|
||||
token::Underscore => "_".to_string(),
|
||||
|
||||
/* Other */
|
||||
token::DocComment(s) => s.as_str().to_string(),
|
||||
token::DocComment(s) => s.to_string(),
|
||||
token::SubstNt(s, _) => format!("${}", s),
|
||||
token::MatchNt(s, t, _, _) => format!("${}:{}", s, t),
|
||||
token::Eof => "<eof>".to_string(),
|
||||
token::Whitespace => " ".to_string(),
|
||||
token::Comment => "/* */".to_string(),
|
||||
token::Shebang(s) => format!("/* shebang: {}*/", s.as_str()),
|
||||
token::Shebang(s) => format!("/* shebang: {}*/", s),
|
||||
|
||||
token::SpecialVarNt(var) => format!("${}", var.as_str()),
|
||||
|
||||
@ -819,7 +819,7 @@ impl<'a> State<'a> {
|
||||
try!(self.head(&visibility_qualified(item.vis,
|
||||
"extern crate")));
|
||||
if let Some(p) = *optional_path {
|
||||
let val = token::get_name(p);
|
||||
let val = p.as_str();
|
||||
if val.contains("-") {
|
||||
try!(self.print_string(&val, ast::CookedStr));
|
||||
} else {
|
||||
@ -2009,7 +2009,7 @@ impl<'a> State<'a> {
|
||||
}
|
||||
|
||||
pub fn print_ident(&mut self, ident: ast::Ident) -> io::Result<()> {
|
||||
try!(word(&mut self.s, &token::get_ident(ident)));
|
||||
try!(word(&mut self.s, &ident.name.as_str()));
|
||||
self.ann.post(self, NodeIdent(&ident))
|
||||
}
|
||||
|
||||
@ -2018,7 +2018,7 @@ impl<'a> State<'a> {
|
||||
}
|
||||
|
||||
pub fn print_name(&mut self, name: ast::Name) -> io::Result<()> {
|
||||
try!(word(&mut self.s, &token::get_name(name)));
|
||||
try!(word(&mut self.s, &name.as_str()));
|
||||
self.ann.post(self, NodeName(&name))
|
||||
}
|
||||
|
||||
|
@ -160,8 +160,7 @@ impl fold::Folder for PreludeInjector {
|
||||
style: ast::AttrOuter,
|
||||
value: P(ast::MetaItem {
|
||||
span: self.span,
|
||||
node: ast::MetaWord(token::get_name(
|
||||
special_idents::prelude_import.name)),
|
||||
node: ast::MetaWord(special_idents::prelude_import.name.as_str()),
|
||||
}),
|
||||
is_sugared_doc: false,
|
||||
},
|
||||
|
@ -20,7 +20,6 @@ extern crate syntax;
|
||||
extern crate rustc;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
use rustc::lint::{Context, LintPass, LintPassObject, LintArray};
|
||||
use rustc::plugin::Registry;
|
||||
|
||||
@ -36,11 +35,10 @@ impl LintPass for Pass {
|
||||
}
|
||||
|
||||
fn check_item(&mut self, cx: &Context, it: &ast::Item) {
|
||||
let name = token::get_ident(it.ident);
|
||||
if &name[..] == "lintme" {
|
||||
cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'");
|
||||
} else if &name[..] == "pleaselintme" {
|
||||
cx.span_lint(PLEASE_LINT, it.span, "item is named 'pleaselintme'");
|
||||
match &*it.ident.name.as_str() {
|
||||
"lintme" => cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'"),
|
||||
"pleaselintme" => cx.span_lint(PLEASE_LINT, it.span, "item is named 'pleaselintme'"),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ extern crate syntax;
|
||||
extern crate rustc;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
use rustc::lint::{Context, LintPass, LintPassObject, LintArray};
|
||||
use rustc::plugin::Registry;
|
||||
|
||||
@ -34,8 +33,7 @@ impl LintPass for Pass {
|
||||
}
|
||||
|
||||
fn check_item(&mut self, cx: &Context, it: &ast::Item) {
|
||||
let name = token::get_ident(it.ident);
|
||||
if &name[..] == "lintme" {
|
||||
if it.ident.name == "lintme" {
|
||||
cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'");
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ extern crate syntax;
|
||||
extern crate rustc;
|
||||
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token;
|
||||
use syntax::ast::{TokenTree, TtToken};
|
||||
use syntax::parse::token;
|
||||
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
|
||||
use syntax::ext::build::AstBuilder; // trait for expr_usize
|
||||
use rustc::plugin::Registry;
|
||||
@ -40,7 +40,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
|
||||
("I", 1)];
|
||||
|
||||
let text = match args {
|
||||
[TtToken(_, token::Ident(s, _))] => token::get_ident(s).to_string(),
|
||||
[TtToken(_, token::Ident(s, _))] => s.to_string(),
|
||||
_ => {
|
||||
cx.span_err(sp, "argument should be a single identifier");
|
||||
return DummyResult::any(sp);
|
||||
|
Loading…
Reference in New Issue
Block a user