mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
Use Names in HIR Items
This commit is contained in:
parent
ae77dbb835
commit
a4af958786
@ -26,7 +26,7 @@ pub use self::Code::*;
|
||||
use front::map::{self, Node};
|
||||
use syntax::abi;
|
||||
use rustc_front::hir::{Block, FnDecl};
|
||||
use syntax::ast::{NodeId, Ident};
|
||||
use syntax::ast::{Name, NodeId};
|
||||
use rustc_front::hir as ast;
|
||||
use syntax::codemap::Span;
|
||||
use rustc_front::visit::FnKind;
|
||||
@ -107,7 +107,7 @@ impl<'a> Code<'a> {
|
||||
/// These are all the components one can extract from a fn item for
|
||||
/// use when implementing FnLikeNode operations.
|
||||
struct ItemFnParts<'a> {
|
||||
ident: Ident,
|
||||
name: Name,
|
||||
decl: &'a ast::FnDecl,
|
||||
unsafety: ast::Unsafety,
|
||||
constness: ast::Constness,
|
||||
@ -189,13 +189,13 @@ impl<'a> FnLikeNode<'a> {
|
||||
|
||||
pub fn kind(self) -> FnKind<'a> {
|
||||
let item = |p: ItemFnParts<'a>| -> FnKind<'a> {
|
||||
FnKind::ItemFn(p.ident.name, p.generics, p.unsafety, p.constness, p.abi, p.vis)
|
||||
FnKind::ItemFn(p.name, p.generics, p.unsafety, p.constness, p.abi, p.vis)
|
||||
};
|
||||
let closure = |_: ClosureParts| {
|
||||
FnKind::Closure
|
||||
};
|
||||
let method = |_, ident: Ident, sig: &'a ast::MethodSig, vis, _, _| {
|
||||
FnKind::Method(ident.name, sig, vis)
|
||||
let method = |_, name: Name, sig: &'a ast::MethodSig, vis, _, _| {
|
||||
FnKind::Method(name, sig, vis)
|
||||
};
|
||||
self.handle(item, method, closure)
|
||||
}
|
||||
@ -203,7 +203,7 @@ impl<'a> FnLikeNode<'a> {
|
||||
fn handle<A, I, M, C>(self, item_fn: I, method: M, closure: C) -> A where
|
||||
I: FnOnce(ItemFnParts<'a>) -> A,
|
||||
M: FnOnce(NodeId,
|
||||
Ident,
|
||||
Name,
|
||||
&'a ast::MethodSig,
|
||||
Option<ast::Visibility>,
|
||||
&'a ast::Block,
|
||||
@ -216,7 +216,7 @@ impl<'a> FnLikeNode<'a> {
|
||||
ast::ItemFn(ref decl, unsafety, constness, abi, ref generics, ref block) =>
|
||||
item_fn(ItemFnParts {
|
||||
id: i.id,
|
||||
ident: i.ident,
|
||||
name: i.name,
|
||||
decl: &**decl,
|
||||
unsafety: unsafety,
|
||||
body: &**block,
|
||||
@ -230,14 +230,14 @@ impl<'a> FnLikeNode<'a> {
|
||||
},
|
||||
map::NodeTraitItem(ti) => match ti.node {
|
||||
ast::MethodTraitItem(ref sig, Some(ref body)) => {
|
||||
method(ti.id, ti.ident, sig, None, body, ti.span)
|
||||
method(ti.id, ti.name, sig, None, body, ti.span)
|
||||
}
|
||||
_ => panic!("trait method FnLikeNode that is not fn-like"),
|
||||
},
|
||||
map::NodeImplItem(ii) => {
|
||||
match ii.node {
|
||||
ast::MethodImplItem(ref sig, ref body) => {
|
||||
method(ii.id, ii.ident, sig, Some(ii.vis), body, ii.span)
|
||||
method(ii.id, ii.name, sig, Some(ii.vis), body, ii.span)
|
||||
}
|
||||
_ => {
|
||||
panic!("impl method FnLikeNode that is not fn-like")
|
||||
|
@ -17,7 +17,7 @@ use metadata::inline::InlinedItem as II;
|
||||
use middle::def_id::DefId;
|
||||
|
||||
use syntax::abi;
|
||||
use syntax::ast::{self, Name, NodeId, Ident, CRATE_NODE_ID, DUMMY_NODE_ID};
|
||||
use syntax::ast::{self, Name, NodeId, CRATE_NODE_ID, DUMMY_NODE_ID};
|
||||
use syntax::codemap::{Span, Spanned};
|
||||
use syntax::parse::token;
|
||||
|
||||
@ -475,14 +475,14 @@ impl<'ast> Map<'ast> {
|
||||
NodeItem(item) => {
|
||||
match item.node {
|
||||
ItemMod(_) | ItemForeignMod(_) => {
|
||||
PathMod(item.ident.name)
|
||||
PathMod(item.name)
|
||||
}
|
||||
_ => PathName(item.ident.name)
|
||||
_ => PathName(item.name)
|
||||
}
|
||||
}
|
||||
NodeForeignItem(i) => PathName(i.ident.name),
|
||||
NodeImplItem(ii) => PathName(ii.ident.name),
|
||||
NodeTraitItem(ti) => PathName(ti.ident.name),
|
||||
NodeForeignItem(i) => PathName(i.name),
|
||||
NodeImplItem(ii) => PathName(ii.name),
|
||||
NodeTraitItem(ti) => PathName(ti.name),
|
||||
NodeVariant(v) => PathName(v.node.name.name),
|
||||
NodeLifetime(lt) => PathName(lt.name),
|
||||
_ => panic!("no path elem for {:?}", node)
|
||||
@ -499,9 +499,9 @@ impl<'ast> Map<'ast> {
|
||||
self.with_path(id, |path| path_to_string(path))
|
||||
}
|
||||
|
||||
fn path_to_str_with_ident(&self, id: NodeId, i: Ident) -> String {
|
||||
fn path_to_str_with_name(&self, id: NodeId, name: Name) -> String {
|
||||
self.with_path(id, |path| {
|
||||
path_to_string(path.chain(Some(PathName(i.name))))
|
||||
path_to_string(path.chain(Some(PathName(name))))
|
||||
})
|
||||
}
|
||||
|
||||
@ -652,7 +652,7 @@ impl<'a, 'ast> NodesMatchingSuffix<'a, 'ast> {
|
||||
match map.find(id) {
|
||||
None => return None,
|
||||
Some(NodeItem(item)) if item_is_mod(&*item) =>
|
||||
return Some((id, item.ident.name)),
|
||||
return Some((id, item.name)),
|
||||
_ => {}
|
||||
}
|
||||
let parent = map.get_parent(id);
|
||||
@ -708,11 +708,11 @@ trait Named {
|
||||
|
||||
impl<T:Named> Named for Spanned<T> { fn name(&self) -> Name { self.node.name() } }
|
||||
|
||||
impl Named for Item { fn name(&self) -> Name { self.ident.name } }
|
||||
impl Named for ForeignItem { fn name(&self) -> Name { self.ident.name } }
|
||||
impl Named for Item { fn name(&self) -> Name { self.name } }
|
||||
impl Named for ForeignItem { fn name(&self) -> Name { self.name } }
|
||||
impl Named for Variant_ { fn name(&self) -> Name { self.name.name } }
|
||||
impl Named for TraitItem { fn name(&self) -> Name { self.ident.name } }
|
||||
impl Named for ImplItem { fn name(&self) -> Name { self.ident.name } }
|
||||
impl Named for TraitItem { fn name(&self) -> Name { self.name } }
|
||||
impl Named for ImplItem { fn name(&self) -> Name { self.name } }
|
||||
|
||||
pub trait FoldOps {
|
||||
fn new_id(&self, id: NodeId) -> NodeId {
|
||||
@ -1040,7 +1040,7 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
|
||||
|
||||
match map.find(id) {
|
||||
Some(NodeItem(item)) => {
|
||||
let path_str = map.path_to_str_with_ident(id, item.ident);
|
||||
let path_str = map.path_to_str_with_name(id, item.name);
|
||||
let item_str = match item.node {
|
||||
ItemExternCrate(..) => "extern crate",
|
||||
ItemUse(..) => "use",
|
||||
@ -1059,25 +1059,25 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
|
||||
format!("{} {}{}", item_str, path_str, id_str)
|
||||
}
|
||||
Some(NodeForeignItem(item)) => {
|
||||
let path_str = map.path_to_str_with_ident(id, item.ident);
|
||||
let path_str = map.path_to_str_with_name(id, item.name);
|
||||
format!("foreign item {}{}", path_str, id_str)
|
||||
}
|
||||
Some(NodeImplItem(ii)) => {
|
||||
match ii.node {
|
||||
ConstImplItem(..) => {
|
||||
format!("assoc const {} in {}{}",
|
||||
ii.ident,
|
||||
ii.name,
|
||||
map.path_to_string(id),
|
||||
id_str)
|
||||
}
|
||||
MethodImplItem(..) => {
|
||||
format!("method {} in {}{}",
|
||||
ii.ident,
|
||||
ii.name,
|
||||
map.path_to_string(id), id_str)
|
||||
}
|
||||
TypeImplItem(_) => {
|
||||
format!("assoc type {} in {}{}",
|
||||
ii.ident,
|
||||
ii.name,
|
||||
map.path_to_string(id),
|
||||
id_str)
|
||||
}
|
||||
@ -1092,7 +1092,7 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
|
||||
|
||||
format!("{} {} in {}{}",
|
||||
kind,
|
||||
ti.ident,
|
||||
ti.name,
|
||||
map.path_to_string(id),
|
||||
id_str)
|
||||
}
|
||||
|
@ -201,17 +201,17 @@ impl<'a> CrateReader<'a> {
|
||||
match i.node {
|
||||
hir::ItemExternCrate(ref path_opt) => {
|
||||
debug!("resolving extern crate stmt. ident: {} path_opt: {:?}",
|
||||
i.ident, path_opt);
|
||||
i.name, path_opt);
|
||||
let name = match *path_opt {
|
||||
Some(name) => {
|
||||
validate_crate_name(Some(self.sess), &name.as_str(),
|
||||
Some(i.span));
|
||||
name.to_string()
|
||||
}
|
||||
None => i.ident.to_string(),
|
||||
None => i.name.to_string(),
|
||||
};
|
||||
Some(CrateInfo {
|
||||
ident: i.ident.to_string(),
|
||||
ident: i.name.to_string(),
|
||||
name: name,
|
||||
id: i.id,
|
||||
should_link: should_link_hir(i),
|
||||
|
@ -426,16 +426,16 @@ fn encode_reexported_static_methods(ecx: &EncodeContext,
|
||||
// encoded metadata for static methods relative to Bar,
|
||||
// but not yet for Foo.
|
||||
//
|
||||
if path_differs || item.ident.name != exp.name {
|
||||
if path_differs || item.name != exp.name {
|
||||
if !encode_reexported_static_base_methods(ecx, rbml_w, exp) {
|
||||
if encode_reexported_static_trait_methods(ecx, rbml_w, exp) {
|
||||
debug!("(encode reexported static methods) {} [trait]",
|
||||
item.ident.name);
|
||||
item.name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
debug!("(encode reexported static methods) {} [base]",
|
||||
item.ident.name);
|
||||
item.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -520,7 +520,7 @@ fn encode_info_for_mod(ecx: &EncodeContext,
|
||||
});
|
||||
|
||||
if let hir::ItemImpl(..) = item.node {
|
||||
let (ident, did) = (item.ident, item.id);
|
||||
let (ident, did) = (item.name, item.id);
|
||||
debug!("(encoding info for module) ... encoding impl {} ({}/{})",
|
||||
ident,
|
||||
did, ecx.tcx.map.node_to_string(did));
|
||||
@ -1014,7 +1014,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
}
|
||||
encode_bounds_and_type_for_item(rbml_w, ecx, item.id);
|
||||
encode_symbol(ecx, rbml_w, item.id);
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
encode_name(rbml_w, item.name);
|
||||
encode_path(rbml_w, path);
|
||||
encode_visibility(rbml_w, vis);
|
||||
encode_stability(rbml_w, stab);
|
||||
@ -1027,7 +1027,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
encode_def_id(rbml_w, def_id);
|
||||
encode_family(rbml_w, 'C');
|
||||
encode_bounds_and_type_for_item(rbml_w, ecx, item.id);
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
encode_name(rbml_w, item.name);
|
||||
encode_path(rbml_w, path);
|
||||
encode_attributes(rbml_w, &item.attrs);
|
||||
encode_inlined_item(ecx, rbml_w, InlinedItemRef::Item(item));
|
||||
@ -1042,7 +1042,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
encode_family(rbml_w, FN_FAMILY);
|
||||
let tps_len = generics.ty_params.len();
|
||||
encode_bounds_and_type_for_item(rbml_w, ecx, item.id);
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
encode_name(rbml_w, item.name);
|
||||
encode_path(rbml_w, path);
|
||||
encode_attributes(rbml_w, &item.attrs);
|
||||
let needs_inline = tps_len > 0 || attr::requests_inline(&item.attrs);
|
||||
@ -1066,7 +1066,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
&item.attrs,
|
||||
item.id,
|
||||
path,
|
||||
item.ident.name,
|
||||
item.name,
|
||||
item.vis);
|
||||
}
|
||||
hir::ItemForeignMod(ref fm) => {
|
||||
@ -1074,7 +1074,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
rbml_w.start_tag(tag_items_data_item);
|
||||
encode_def_id(rbml_w, def_id);
|
||||
encode_family(rbml_w, 'n');
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
encode_name(rbml_w, item.name);
|
||||
encode_path(rbml_w, path);
|
||||
|
||||
// Encode all the items in this module.
|
||||
@ -1092,7 +1092,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
encode_def_id(rbml_w, def_id);
|
||||
encode_family(rbml_w, 'y');
|
||||
encode_bounds_and_type_for_item(rbml_w, ecx, item.id);
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
encode_name(rbml_w, item.name);
|
||||
encode_path(rbml_w, path);
|
||||
encode_visibility(rbml_w, vis);
|
||||
encode_stability(rbml_w, stab);
|
||||
@ -1106,7 +1106,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
encode_family(rbml_w, 't');
|
||||
encode_item_variances(rbml_w, ecx, item.id);
|
||||
encode_bounds_and_type_for_item(rbml_w, ecx, item.id);
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
encode_name(rbml_w, item.name);
|
||||
encode_attributes(rbml_w, &item.attrs);
|
||||
encode_repr_attrs(rbml_w, ecx, &item.attrs);
|
||||
for v in &enum_definition.variants {
|
||||
@ -1146,7 +1146,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
encode_bounds_and_type_for_item(rbml_w, ecx, item.id);
|
||||
|
||||
encode_item_variances(rbml_w, ecx, item.id);
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
encode_name(rbml_w, item.name);
|
||||
encode_attributes(rbml_w, &item.attrs);
|
||||
encode_path(rbml_w, path.clone());
|
||||
encode_stability(rbml_w, stab);
|
||||
@ -1168,7 +1168,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
// If this is a tuple-like struct, encode the type of the constructor.
|
||||
match struct_def.ctor_id {
|
||||
Some(ctor_id) => {
|
||||
encode_info_for_struct_ctor(ecx, rbml_w, item.ident.name,
|
||||
encode_info_for_struct_ctor(ecx, rbml_w, item.name,
|
||||
ctor_id, index, def_id.node);
|
||||
}
|
||||
None => {}
|
||||
@ -1179,7 +1179,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
rbml_w.start_tag(tag_items_data_item);
|
||||
encode_def_id(rbml_w, def_id);
|
||||
encode_family(rbml_w, 'd');
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
encode_name(rbml_w, item.name);
|
||||
encode_unsafety(rbml_w, unsafety);
|
||||
|
||||
let trait_ref = tcx.impl_trait_ref(DefId::local(item.id)).unwrap();
|
||||
@ -1197,7 +1197,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
encode_def_id(rbml_w, def_id);
|
||||
encode_family(rbml_w, 'i');
|
||||
encode_bounds_and_type_for_item(rbml_w, ecx, item.id);
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
encode_name(rbml_w, item.name);
|
||||
encode_attributes(rbml_w, &item.attrs);
|
||||
encode_unsafety(rbml_w, unsafety);
|
||||
encode_polarity(rbml_w, polarity);
|
||||
@ -1306,7 +1306,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
encode_predicates(rbml_w, ecx, &tcx.lookup_super_predicates(def_id),
|
||||
tag_item_super_predicates);
|
||||
encode_trait_ref(rbml_w, ecx, trait_def.trait_ref, tag_item_trait_ref);
|
||||
encode_name(rbml_w, item.ident.name);
|
||||
encode_name(rbml_w, item.name);
|
||||
encode_attributes(rbml_w, &item.attrs);
|
||||
encode_visibility(rbml_w, vis);
|
||||
encode_stability(rbml_w, stab);
|
||||
@ -1483,7 +1483,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
|
||||
hir::ForeignItemFn(ref fndecl, _) => {
|
||||
encode_family(rbml_w, FN_FAMILY);
|
||||
encode_bounds_and_type_for_item(rbml_w, ecx, nitem.id);
|
||||
encode_name(rbml_w, nitem.ident.name);
|
||||
encode_name(rbml_w, nitem.name);
|
||||
if abi == abi::RustIntrinsic || abi == abi::PlatformIntrinsic {
|
||||
encode_inlined_item(ecx, rbml_w, InlinedItemRef::Foreign(nitem));
|
||||
}
|
||||
@ -1504,7 +1504,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
|
||||
let stab = stability::lookup(ecx.tcx, DefId::local(nitem.id));
|
||||
encode_stability(rbml_w, stab);
|
||||
encode_symbol(ecx, rbml_w, nitem.id);
|
||||
encode_name(rbml_w, nitem.ident.name);
|
||||
encode_name(rbml_w, nitem.name);
|
||||
}
|
||||
}
|
||||
encode_path(rbml_w, path);
|
||||
@ -1528,7 +1528,7 @@ fn my_visit_foreign_item(ni: &hir::ForeignItem,
|
||||
index: &mut Vec<IndexEntry>) {
|
||||
debug!("writing foreign item {}::{}",
|
||||
ecx.tcx.map.path_to_string(ni.id),
|
||||
ni.ident);
|
||||
ni.name);
|
||||
|
||||
let abi = ecx.tcx.map.get_foreign_abi(ni.id);
|
||||
ecx.tcx.map.with_path(ni.id, |path| {
|
||||
|
@ -155,16 +155,16 @@ pub fn decode_inlined_item<'tcx>(cdata: &cstore::crate_metadata,
|
||||
let raw_ii = decode_ast(ast_doc);
|
||||
let ii = ast_map::map_decoded_item(&dcx.tcx.map, path, raw_ii, dcx);
|
||||
|
||||
let ident = match *ii {
|
||||
InlinedItem::Item(ref i) => i.ident,
|
||||
InlinedItem::Foreign(ref i) => i.ident,
|
||||
InlinedItem::TraitItem(_, ref ti) => ti.ident,
|
||||
InlinedItem::ImplItem(_, ref ii) => ii.ident
|
||||
let name = match *ii {
|
||||
InlinedItem::Item(ref i) => i.name,
|
||||
InlinedItem::Foreign(ref i) => i.name,
|
||||
InlinedItem::TraitItem(_, ref ti) => ti.name,
|
||||
InlinedItem::ImplItem(_, ref ii) => ii.name
|
||||
};
|
||||
debug!("Fn named: {}", ident);
|
||||
debug!("Fn named: {}", name);
|
||||
debug!("< Decoded inlined fn: {}::{}",
|
||||
path_as_str.unwrap(),
|
||||
ident);
|
||||
name);
|
||||
region::resolve_inlined_item(&tcx.sess, &tcx.region_maps, ii);
|
||||
decode_side_tables(dcx, ast_doc);
|
||||
match *ii {
|
||||
|
@ -1109,7 +1109,7 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
|
||||
match selection {
|
||||
traits::VtableImpl(ref impl_data) => {
|
||||
match tcx.associated_consts(impl_data.impl_def_id)
|
||||
.iter().find(|ic| ic.name == ti.ident.name) {
|
||||
.iter().find(|ic| ic.name == ti.name) {
|
||||
Some(ic) => lookup_const_by_id(tcx, ic.def_id, None),
|
||||
None => match ti.node {
|
||||
hir::ConstTraitItem(_, Some(ref expr)) => Some(&*expr),
|
||||
|
@ -520,7 +520,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
|
||||
self.warn_dead_code(
|
||||
item.id,
|
||||
item.span,
|
||||
item.ident.name,
|
||||
item.name,
|
||||
item.node.descriptive_variant()
|
||||
);
|
||||
} else {
|
||||
@ -541,7 +541,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
|
||||
|
||||
fn visit_foreign_item(&mut self, fi: &hir::ForeignItem) {
|
||||
if !self.symbol_is_live(fi.id, None) {
|
||||
self.warn_dead_code(fi.id, fi.span, fi.ident.name, fi.node.descriptive_variant());
|
||||
self.warn_dead_code(fi.id, fi.span, fi.name, fi.node.descriptive_variant());
|
||||
}
|
||||
visit::walk_foreign_item(self, fi);
|
||||
}
|
||||
@ -560,14 +560,14 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
|
||||
hir::ConstImplItem(_, ref expr) => {
|
||||
if !self.symbol_is_live(impl_item.id, None) {
|
||||
self.warn_dead_code(impl_item.id, impl_item.span,
|
||||
impl_item.ident.name, "associated const");
|
||||
impl_item.name, "associated const");
|
||||
}
|
||||
visit::walk_expr(self, expr)
|
||||
}
|
||||
hir::MethodImplItem(_, ref body) => {
|
||||
if !self.symbol_is_live(impl_item.id, None) {
|
||||
self.warn_dead_code(impl_item.id, impl_item.span,
|
||||
impl_item.ident.name, "method");
|
||||
impl_item.name, "method");
|
||||
}
|
||||
visit::walk_block(self, body)
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ fn entry_point_type(item: &Item, depth: usize) -> EntryPointType {
|
||||
EntryPointType::Start
|
||||
} else if attr::contains_name(&item.attrs, "main") {
|
||||
EntryPointType::MainAttr
|
||||
} else if item.ident.name == "main" {
|
||||
} else if item.name == "main" {
|
||||
if depth == 1 {
|
||||
// This is a top-level function so can be 'main'
|
||||
EntryPointType::MainNamed
|
||||
|
@ -284,7 +284,7 @@ trait ErrorReportingHelpers<'tcx> {
|
||||
decl: &hir::FnDecl,
|
||||
unsafety: hir::Unsafety,
|
||||
constness: hir::Constness,
|
||||
ident: ast::Ident,
|
||||
name: ast::Name,
|
||||
opt_explicit_self: Option<&hir::ExplicitSelf_>,
|
||||
generics: &hir::Generics,
|
||||
span: Span);
|
||||
@ -978,7 +978,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
match item.node {
|
||||
hir::ItemFn(ref fn_decl, unsafety, constness, _, ref gen, _) => {
|
||||
Some((fn_decl, gen, unsafety, constness,
|
||||
item.ident, None, item.span))
|
||||
item.name, None, item.span))
|
||||
},
|
||||
_ => None
|
||||
}
|
||||
@ -990,7 +990,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
&sig.generics,
|
||||
sig.unsafety,
|
||||
sig.constness,
|
||||
item.ident,
|
||||
item.name,
|
||||
Some(&sig.explicit_self.node),
|
||||
item.span))
|
||||
}
|
||||
@ -1004,7 +1004,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
&sig.generics,
|
||||
sig.unsafety,
|
||||
sig.constness,
|
||||
item.ident,
|
||||
item.name,
|
||||
Some(&sig.explicit_self.node),
|
||||
item.span))
|
||||
}
|
||||
@ -1576,11 +1576,11 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
decl: &hir::FnDecl,
|
||||
unsafety: hir::Unsafety,
|
||||
constness: hir::Constness,
|
||||
ident: ast::Ident,
|
||||
name: ast::Name,
|
||||
opt_explicit_self: Option<&hir::ExplicitSelf_>,
|
||||
generics: &hir::Generics,
|
||||
span: Span) {
|
||||
let suggested_fn = pprust::fun_to_string(decl, unsafety, constness, ident,
|
||||
let suggested_fn = pprust::fun_to_string(decl, unsafety, constness, name,
|
||||
opt_explicit_self, generics);
|
||||
let msg = format!("consider using an explicit lifetime \
|
||||
parameter as shown: {}", suggested_fn);
|
||||
|
@ -336,7 +336,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.name == "__test" { return }
|
||||
if item.span == DUMMY_SP && item.name == "__test" { return }
|
||||
|
||||
check_item(self.tcx, item, true,
|
||||
&mut |id, sp, stab| self.check(id, sp, stab));
|
||||
@ -393,7 +393,7 @@ pub fn check_item(tcx: &ty::ctxt, item: &hir::Item, warn_about_defns: bool,
|
||||
|
||||
for impl_item in impl_items {
|
||||
let item = trait_items.iter().find(|item| {
|
||||
item.name() == impl_item.ident.name
|
||||
item.name() == impl_item.name
|
||||
}).unwrap();
|
||||
if warn_about_defns {
|
||||
maybe_do_stability_check(tcx, item.def_id(), impl_item.span, cb);
|
||||
|
@ -195,7 +195,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
||||
-> Option<ast::NodeId> {
|
||||
assert!(idx < names.len());
|
||||
for item in &m.items {
|
||||
if item.ident.to_string() == names[idx] {
|
||||
if item.name.to_string() == names[idx] {
|
||||
return search(this, &**item, idx+1, names);
|
||||
}
|
||||
}
|
||||
|
@ -837,9 +837,9 @@ pub fn noop_fold_item_underscore<T: Folder>(i: Item_, folder: &mut T) -> Item_ {
|
||||
|
||||
pub fn noop_fold_trait_item<T: Folder>(i: P<TraitItem>, folder: &mut T)
|
||||
-> SmallVector<P<TraitItem>> {
|
||||
SmallVector::one(i.map(|TraitItem {id, ident, attrs, node, span}| TraitItem {
|
||||
SmallVector::one(i.map(|TraitItem {id, name, attrs, node, span}| TraitItem {
|
||||
id: folder.new_id(id),
|
||||
ident: fold_ident(folder, ident),
|
||||
name: folder.fold_name(name),
|
||||
attrs: fold_attrs(attrs, folder),
|
||||
node: match node {
|
||||
ConstTraitItem(ty, default) => {
|
||||
@ -861,9 +861,9 @@ pub fn noop_fold_trait_item<T: Folder>(i: P<TraitItem>, folder: &mut T)
|
||||
|
||||
pub fn noop_fold_impl_item<T: Folder>(i: P<ImplItem>, folder: &mut T)
|
||||
-> SmallVector<P<ImplItem>> {
|
||||
SmallVector::one(i.map(|ImplItem {id, ident, attrs, node, vis, span}| ImplItem {
|
||||
SmallVector::one(i.map(|ImplItem {id, name, attrs, node, vis, span}| ImplItem {
|
||||
id: folder.new_id(id),
|
||||
ident: fold_ident(folder, ident),
|
||||
name: folder.fold_name(name),
|
||||
attrs: fold_attrs(attrs, folder),
|
||||
vis: vis,
|
||||
node: match node {
|
||||
@ -892,7 +892,7 @@ pub fn noop_fold_crate<T: Folder>(Crate {module, attrs, config, span, exported_m
|
||||
let config = folder.fold_meta_items(config);
|
||||
|
||||
let mut items = folder.fold_item(P(hir::Item {
|
||||
ident: token::special_idents::invalid,
|
||||
name: token::special_idents::invalid.name,
|
||||
attrs: attrs,
|
||||
id: DUMMY_NODE_ID,
|
||||
vis: hir::Public,
|
||||
@ -932,7 +932,7 @@ pub fn noop_fold_item<T: Folder>(i: P<Item>, folder: &mut T) -> SmallVector<P<It
|
||||
}
|
||||
|
||||
// fold one item into exactly one item
|
||||
pub fn noop_fold_item_simple<T: Folder>(Item {id, ident, attrs, node, vis, span}: Item,
|
||||
pub fn noop_fold_item_simple<T: Folder>(Item {id, name, attrs, node, vis, span}: Item,
|
||||
folder: &mut T) -> Item {
|
||||
let id = folder.new_id(id);
|
||||
let node = folder.fold_item_underscore(node);
|
||||
@ -947,7 +947,7 @@ pub fn noop_fold_item_simple<T: Folder>(Item {id, ident, attrs, node, vis, span}
|
||||
|
||||
Item {
|
||||
id: id,
|
||||
ident: fold_ident(folder, ident),
|
||||
name: folder.fold_name(name),
|
||||
attrs: fold_attrs(attrs, folder),
|
||||
node: node,
|
||||
vis: vis,
|
||||
@ -956,9 +956,9 @@ pub fn noop_fold_item_simple<T: Folder>(Item {id, ident, attrs, node, vis, span}
|
||||
}
|
||||
|
||||
pub fn noop_fold_foreign_item<T: Folder>(ni: P<ForeignItem>, folder: &mut T) -> P<ForeignItem> {
|
||||
ni.map(|ForeignItem {id, ident, attrs, node, span, vis}| ForeignItem {
|
||||
ni.map(|ForeignItem {id, name, attrs, node, span, vis}| ForeignItem {
|
||||
id: folder.new_id(id),
|
||||
ident: fold_ident(folder, ident),
|
||||
name: folder.fold_name(name),
|
||||
attrs: fold_attrs(attrs, folder),
|
||||
node: match node {
|
||||
ForeignItemFn(fdec, generics) => {
|
||||
|
@ -770,7 +770,7 @@ pub struct MethodSig {
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct TraitItem {
|
||||
pub id: NodeId,
|
||||
pub ident: Ident,
|
||||
pub name: Name,
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub node: TraitItem_,
|
||||
pub span: Span,
|
||||
@ -786,7 +786,7 @@ pub enum TraitItem_ {
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct ImplItem {
|
||||
pub id: NodeId,
|
||||
pub ident: Ident,
|
||||
pub name: Name,
|
||||
pub vis: Visibility,
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub node: ImplItem_,
|
||||
@ -1190,7 +1190,7 @@ pub struct StructDef {
|
||||
/// The name might be a dummy name in case of anonymous items
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct Item {
|
||||
pub ident: Ident,
|
||||
pub name: Name,
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub id: NodeId,
|
||||
pub node: Item_,
|
||||
@ -1264,7 +1264,7 @@ impl Item_ {
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct ForeignItem {
|
||||
pub ident: Ident,
|
||||
pub name: Name,
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub node: ForeignItem_,
|
||||
pub id: NodeId,
|
||||
|
@ -466,7 +466,7 @@ pub fn lower_item_underscore(i: &Item_) -> hir::Item_ {
|
||||
pub fn lower_trait_item(i: &TraitItem) -> P<hir::TraitItem> {
|
||||
P(hir::TraitItem {
|
||||
id: i.id,
|
||||
ident: i.ident,
|
||||
name: i.ident.name,
|
||||
attrs: i.attrs.clone(),
|
||||
node: match i.node {
|
||||
ConstTraitItem(ref ty, ref default) => {
|
||||
@ -489,7 +489,7 @@ pub fn lower_trait_item(i: &TraitItem) -> P<hir::TraitItem> {
|
||||
pub fn lower_impl_item(i: &ImplItem) -> P<hir::ImplItem> {
|
||||
P(hir::ImplItem {
|
||||
id: i.id,
|
||||
ident: i.ident,
|
||||
name: i.ident.name,
|
||||
attrs: i.attrs.clone(),
|
||||
vis: lower_visibility(i.vis),
|
||||
node: match i.node {
|
||||
@ -546,7 +546,7 @@ pub fn lower_item_simple(i: &Item) -> hir::Item {
|
||||
|
||||
hir::Item {
|
||||
id: i.id,
|
||||
ident: i.ident,
|
||||
name: i.ident.name,
|
||||
attrs: i.attrs.clone(),
|
||||
node: node,
|
||||
vis: lower_visibility(i.vis),
|
||||
@ -557,7 +557,7 @@ pub fn lower_item_simple(i: &Item) -> hir::Item {
|
||||
pub fn lower_foreign_item(i: &ForeignItem) -> P<hir::ForeignItem> {
|
||||
P(hir::ForeignItem {
|
||||
id: i.id,
|
||||
ident: i.ident,
|
||||
name: i.ident.name,
|
||||
attrs: i.attrs.clone(),
|
||||
node: match i.node {
|
||||
ForeignItemFn(ref fdec, ref generics) => {
|
||||
|
@ -271,7 +271,7 @@ pub fn ident_to_string(id: &ast::Ident) -> String {
|
||||
pub fn fun_to_string(decl: &hir::FnDecl,
|
||||
unsafety: hir::Unsafety,
|
||||
constness: hir::Constness,
|
||||
name: ast::Ident,
|
||||
name: ast::Name,
|
||||
opt_explicit_self: Option<&hir::ExplicitSelf_>,
|
||||
generics: &hir::Generics)
|
||||
-> String {
|
||||
@ -557,7 +557,7 @@ impl<'a> State<'a> {
|
||||
try!(self.head(""));
|
||||
try!(self.print_fn(decl, hir::Unsafety::Normal,
|
||||
hir::Constness::NotConst,
|
||||
abi::Rust, Some(item.ident),
|
||||
abi::Rust, Some(item.name),
|
||||
generics, None, item.vis));
|
||||
try!(self.end()); // end head-ibox
|
||||
try!(word(&mut self.s, ";"));
|
||||
@ -569,7 +569,7 @@ impl<'a> State<'a> {
|
||||
if m {
|
||||
try!(self.word_space("mut"));
|
||||
}
|
||||
try!(self.print_ident(item.ident));
|
||||
try!(self.print_name(item.name));
|
||||
try!(self.word_space(":"));
|
||||
try!(self.print_type(&**t));
|
||||
try!(word(&mut self.s, ";"));
|
||||
@ -580,7 +580,7 @@ impl<'a> State<'a> {
|
||||
}
|
||||
|
||||
fn print_associated_const(&mut self,
|
||||
ident: ast::Ident,
|
||||
name: ast::Name,
|
||||
ty: &hir::Ty,
|
||||
default: Option<&hir::Expr>,
|
||||
vis: hir::Visibility)
|
||||
@ -588,7 +588,7 @@ impl<'a> State<'a> {
|
||||
{
|
||||
try!(word(&mut self.s, &visibility_qualified(vis, "")));
|
||||
try!(self.word_space("const"));
|
||||
try!(self.print_ident(ident));
|
||||
try!(self.print_name(name));
|
||||
try!(self.word_space(":"));
|
||||
try!(self.print_type(ty));
|
||||
if let Some(expr) = default {
|
||||
@ -600,12 +600,12 @@ impl<'a> State<'a> {
|
||||
}
|
||||
|
||||
fn print_associated_type(&mut self,
|
||||
ident: ast::Ident,
|
||||
name: ast::Name,
|
||||
bounds: Option<&hir::TyParamBounds>,
|
||||
ty: Option<&hir::Ty>)
|
||||
-> io::Result<()> {
|
||||
try!(self.word_space("type"));
|
||||
try!(self.print_ident(ident));
|
||||
try!(self.print_name(name));
|
||||
if let Some(bounds) = bounds {
|
||||
try!(self.print_bounds(":", bounds));
|
||||
}
|
||||
@ -638,7 +638,7 @@ impl<'a> State<'a> {
|
||||
try!(word(&mut self.s, "as"));
|
||||
try!(space(&mut self.s));
|
||||
}
|
||||
try!(self.print_ident(item.ident));
|
||||
try!(self.print_name(item.name));
|
||||
try!(word(&mut self.s, ";"));
|
||||
try!(self.end()); // end inner head-block
|
||||
try!(self.end()); // end outer head-block
|
||||
@ -657,7 +657,7 @@ impl<'a> State<'a> {
|
||||
if m == hir::MutMutable {
|
||||
try!(self.word_space("mut"));
|
||||
}
|
||||
try!(self.print_ident(item.ident));
|
||||
try!(self.print_name(item.name));
|
||||
try!(self.word_space(":"));
|
||||
try!(self.print_type(&**ty));
|
||||
try!(space(&mut self.s));
|
||||
@ -671,7 +671,7 @@ impl<'a> State<'a> {
|
||||
hir::ItemConst(ref ty, ref expr) => {
|
||||
try!(self.head(&visibility_qualified(item.vis,
|
||||
"const")));
|
||||
try!(self.print_ident(item.ident));
|
||||
try!(self.print_name(item.name));
|
||||
try!(self.word_space(":"));
|
||||
try!(self.print_type(&**ty));
|
||||
try!(space(&mut self.s));
|
||||
@ -689,7 +689,7 @@ impl<'a> State<'a> {
|
||||
unsafety,
|
||||
constness,
|
||||
abi,
|
||||
Some(item.ident),
|
||||
Some(item.name),
|
||||
typarams,
|
||||
None,
|
||||
item.vis
|
||||
@ -700,7 +700,7 @@ impl<'a> State<'a> {
|
||||
hir::ItemMod(ref _mod) => {
|
||||
try!(self.head(&visibility_qualified(item.vis,
|
||||
"mod")));
|
||||
try!(self.print_ident(item.ident));
|
||||
try!(self.print_name(item.name));
|
||||
try!(self.nbsp());
|
||||
try!(self.bopen());
|
||||
try!(self.print_mod(_mod, &item.attrs));
|
||||
@ -717,7 +717,7 @@ impl<'a> State<'a> {
|
||||
try!(self.ibox(indent_unit));
|
||||
try!(self.ibox(0));
|
||||
try!(self.word_nbsp(&visibility_qualified(item.vis, "type")));
|
||||
try!(self.print_ident(item.ident));
|
||||
try!(self.print_name(item.name));
|
||||
try!(self.print_generics(params));
|
||||
try!(self.end()); // end the inner ibox
|
||||
|
||||
@ -732,14 +732,14 @@ impl<'a> State<'a> {
|
||||
try!(self.print_enum_def(
|
||||
enum_definition,
|
||||
params,
|
||||
item.ident,
|
||||
item.name,
|
||||
item.span,
|
||||
item.vis
|
||||
));
|
||||
}
|
||||
hir::ItemStruct(ref struct_def, ref generics) => {
|
||||
try!(self.head(&visibility_qualified(item.vis,"struct")));
|
||||
try!(self.print_struct(&**struct_def, generics, item.ident, item.span));
|
||||
try!(self.print_struct(&**struct_def, generics, item.name, item.span));
|
||||
}
|
||||
|
||||
hir::ItemDefaultImpl(unsafety, ref trait_ref) => {
|
||||
@ -802,7 +802,7 @@ impl<'a> State<'a> {
|
||||
try!(self.print_visibility(item.vis));
|
||||
try!(self.print_unsafety(unsafety));
|
||||
try!(self.word_nbsp("trait"));
|
||||
try!(self.print_ident(item.ident));
|
||||
try!(self.print_name(item.name));
|
||||
try!(self.print_generics(generics));
|
||||
let mut real_bounds = Vec::with_capacity(bounds.len());
|
||||
for b in bounds.iter() {
|
||||
@ -853,11 +853,11 @@ impl<'a> State<'a> {
|
||||
}
|
||||
|
||||
pub fn print_enum_def(&mut self, enum_definition: &hir::EnumDef,
|
||||
generics: &hir::Generics, ident: ast::Ident,
|
||||
generics: &hir::Generics, name: ast::Name,
|
||||
span: codemap::Span,
|
||||
visibility: hir::Visibility) -> io::Result<()> {
|
||||
try!(self.head(&visibility_qualified(visibility, "enum")));
|
||||
try!(self.print_ident(ident));
|
||||
try!(self.print_name(name));
|
||||
try!(self.print_generics(generics));
|
||||
try!(self.print_where_clause(&generics.where_clause));
|
||||
try!(space(&mut self.s));
|
||||
@ -891,9 +891,9 @@ impl<'a> State<'a> {
|
||||
pub fn print_struct(&mut self,
|
||||
struct_def: &hir::StructDef,
|
||||
generics: &hir::Generics,
|
||||
ident: ast::Ident,
|
||||
name: ast::Name,
|
||||
span: codemap::Span) -> io::Result<()> {
|
||||
try!(self.print_ident(ident));
|
||||
try!(self.print_name(name));
|
||||
try!(self.print_generics(generics));
|
||||
if ::util::struct_def_is_tuple_like(struct_def) {
|
||||
if !struct_def.fields.is_empty() {
|
||||
@ -958,7 +958,7 @@ impl<'a> State<'a> {
|
||||
hir::StructVariantKind(ref struct_def) => {
|
||||
try!(self.head(""));
|
||||
let generics = ::util::empty_generics();
|
||||
try!(self.print_struct(&**struct_def, &generics, v.node.name, v.span));
|
||||
try!(self.print_struct(&**struct_def, &generics, v.node.name.name, v.span));
|
||||
}
|
||||
}
|
||||
match v.node.disr_expr {
|
||||
@ -972,7 +972,7 @@ impl<'a> State<'a> {
|
||||
}
|
||||
|
||||
pub fn print_method_sig(&mut self,
|
||||
ident: ast::Ident,
|
||||
name: ast::Name,
|
||||
m: &hir::MethodSig,
|
||||
vis: hir::Visibility)
|
||||
-> io::Result<()> {
|
||||
@ -980,7 +980,7 @@ impl<'a> State<'a> {
|
||||
m.unsafety,
|
||||
m.constness,
|
||||
m.abi,
|
||||
Some(ident),
|
||||
Some(name),
|
||||
&m.generics,
|
||||
Some(&m.explicit_self.node),
|
||||
vis)
|
||||
@ -994,7 +994,7 @@ impl<'a> State<'a> {
|
||||
try!(self.print_outer_attributes(&ti.attrs));
|
||||
match ti.node {
|
||||
hir::ConstTraitItem(ref ty, ref default) => {
|
||||
try!(self.print_associated_const(ti.ident, &ty,
|
||||
try!(self.print_associated_const(ti.name, &ty,
|
||||
default.as_ref().map(|expr| &**expr),
|
||||
hir::Inherited));
|
||||
}
|
||||
@ -1002,7 +1002,7 @@ impl<'a> State<'a> {
|
||||
if body.is_some() {
|
||||
try!(self.head(""));
|
||||
}
|
||||
try!(self.print_method_sig(ti.ident, sig, hir::Inherited));
|
||||
try!(self.print_method_sig(ti.name, sig, hir::Inherited));
|
||||
if let Some(ref body) = *body {
|
||||
try!(self.nbsp());
|
||||
try!(self.print_block_with_attrs(body, &ti.attrs));
|
||||
@ -1011,7 +1011,7 @@ impl<'a> State<'a> {
|
||||
}
|
||||
}
|
||||
hir::TypeTraitItem(ref bounds, ref default) => {
|
||||
try!(self.print_associated_type(ti.ident, Some(bounds),
|
||||
try!(self.print_associated_type(ti.name, Some(bounds),
|
||||
default.as_ref().map(|ty| &**ty)));
|
||||
}
|
||||
}
|
||||
@ -1025,16 +1025,16 @@ impl<'a> State<'a> {
|
||||
try!(self.print_outer_attributes(&ii.attrs));
|
||||
match ii.node {
|
||||
hir::ConstImplItem(ref ty, ref expr) => {
|
||||
try!(self.print_associated_const(ii.ident, &ty, Some(&expr), ii.vis));
|
||||
try!(self.print_associated_const(ii.name, &ty, Some(&expr), ii.vis));
|
||||
}
|
||||
hir::MethodImplItem(ref sig, ref body) => {
|
||||
try!(self.head(""));
|
||||
try!(self.print_method_sig(ii.ident, sig, ii.vis));
|
||||
try!(self.print_method_sig(ii.name, sig, ii.vis));
|
||||
try!(self.nbsp());
|
||||
try!(self.print_block_with_attrs(body, &ii.attrs));
|
||||
}
|
||||
hir::TypeImplItem(ref ty) => {
|
||||
try!(self.print_associated_type(ii.ident, None, Some(ty)));
|
||||
try!(self.print_associated_type(ii.name, None, Some(ty)));
|
||||
}
|
||||
}
|
||||
self.ann.post(self, NodeSubItem(ii.id))
|
||||
@ -1928,7 +1928,7 @@ impl<'a> State<'a> {
|
||||
unsafety: hir::Unsafety,
|
||||
constness: hir::Constness,
|
||||
abi: abi::Abi,
|
||||
name: Option<ast::Ident>,
|
||||
name: Option<ast::Name>,
|
||||
generics: &hir::Generics,
|
||||
opt_explicit_self: Option<&hir::ExplicitSelf_>,
|
||||
vis: hir::Visibility) -> io::Result<()> {
|
||||
@ -1936,7 +1936,7 @@ impl<'a> State<'a> {
|
||||
|
||||
if let Some(name) = name {
|
||||
try!(self.nbsp());
|
||||
try!(self.print_ident(name));
|
||||
try!(self.print_name(name));
|
||||
}
|
||||
try!(self.print_generics(generics));
|
||||
try!(self.print_fn_args_and_ret(decl, opt_explicit_self));
|
||||
@ -2299,7 +2299,7 @@ impl<'a> State<'a> {
|
||||
unsafety,
|
||||
hir::Constness::NotConst,
|
||||
abi,
|
||||
name,
|
||||
name.map(|x| x.name),
|
||||
&generics,
|
||||
opt_explicit_self,
|
||||
hir::Inherited));
|
||||
|
@ -198,7 +198,7 @@ pub fn walk_trait_ref<'v,V>(visitor: &mut V,
|
||||
}
|
||||
|
||||
pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
|
||||
visitor.visit_name(item.span, item.ident.name);
|
||||
visitor.visit_name(item.span, item.name);
|
||||
match item.node {
|
||||
ItemExternCrate(..) => {}
|
||||
ItemUse(ref vp) => {
|
||||
@ -227,7 +227,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
|
||||
visitor.visit_expr(&**expr);
|
||||
}
|
||||
ItemFn(ref declaration, unsafety, constness, abi, ref generics, ref body) => {
|
||||
visitor.visit_fn(FnKind::ItemFn(item.ident.name, generics, unsafety,
|
||||
visitor.visit_fn(FnKind::ItemFn(item.name, generics, unsafety,
|
||||
constness, abi, item.vis),
|
||||
&**declaration,
|
||||
&**body,
|
||||
@ -271,7 +271,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
|
||||
ItemStruct(ref struct_definition, ref generics) => {
|
||||
visitor.visit_generics(generics);
|
||||
visitor.visit_struct_def(&**struct_definition,
|
||||
item.ident.name,
|
||||
item.name,
|
||||
generics,
|
||||
item.id)
|
||||
}
|
||||
@ -503,7 +503,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
|
||||
|
||||
pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
foreign_item: &'v ForeignItem) {
|
||||
visitor.visit_name(foreign_item.span, foreign_item.ident.name);
|
||||
visitor.visit_name(foreign_item.span, foreign_item.name);
|
||||
|
||||
match foreign_item.node {
|
||||
ForeignItemFn(ref function_declaration, ref generics) => {
|
||||
@ -611,7 +611,7 @@ pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
}
|
||||
|
||||
pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v TraitItem) {
|
||||
visitor.visit_name(trait_item.span, trait_item.ident.name);
|
||||
visitor.visit_name(trait_item.span, trait_item.name);
|
||||
for attr in &trait_item.attrs {
|
||||
visitor.visit_attribute(attr);
|
||||
}
|
||||
@ -628,7 +628,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
|
||||
walk_fn_decl(visitor, &sig.decl);
|
||||
}
|
||||
MethodTraitItem(ref sig, Some(ref body)) => {
|
||||
visitor.visit_fn(FnKind::Method(trait_item.ident.name, sig, None), &sig.decl,
|
||||
visitor.visit_fn(FnKind::Method(trait_item.name, sig, None), &sig.decl,
|
||||
body, trait_item.span, trait_item.id);
|
||||
}
|
||||
TypeTraitItem(ref bounds, ref default) => {
|
||||
@ -639,7 +639,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
|
||||
}
|
||||
|
||||
pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplItem) {
|
||||
visitor.visit_name(impl_item.span, impl_item.ident.name);
|
||||
visitor.visit_name(impl_item.span, impl_item.name);
|
||||
for attr in &impl_item.attrs {
|
||||
visitor.visit_attribute(attr);
|
||||
}
|
||||
@ -649,8 +649,8 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
|
||||
visitor.visit_expr(expr);
|
||||
}
|
||||
MethodImplItem(ref sig, ref body) => {
|
||||
visitor.visit_fn(FnKind::Method(impl_item.ident.name, sig, Some(impl_item.vis)),
|
||||
&sig.decl, body, impl_item.span, impl_item.id);
|
||||
visitor.visit_fn(FnKind::Method(impl_item.name, sig, Some(impl_item.vis)), &sig.decl,
|
||||
body, impl_item.span, impl_item.id);
|
||||
}
|
||||
TypeImplItem(ref ty) => {
|
||||
visitor.visit_ty(ty);
|
||||
|
@ -1731,7 +1731,7 @@ impl LateLintPass for InvalidNoMangleItems {
|
||||
if attr::contains_name(&it.attrs, "no_mangle") &&
|
||||
!cx.exported_items.contains(&it.id) {
|
||||
let msg = format!("function {} is marked #[no_mangle], but not exported",
|
||||
it.ident);
|
||||
it.name);
|
||||
cx.span_lint(PRIVATE_NO_MANGLE_FNS, it.span, &msg);
|
||||
}
|
||||
},
|
||||
@ -1739,7 +1739,7 @@ impl LateLintPass for InvalidNoMangleItems {
|
||||
if attr::contains_name(&it.attrs, "no_mangle") &&
|
||||
!cx.exported_items.contains(&it.id) {
|
||||
let msg = format!("static {} is marked #[no_mangle], but not exported",
|
||||
it.ident);
|
||||
it.name);
|
||||
cx.span_lint(PRIVATE_NO_MANGLE_STATICS, it.span, &msg);
|
||||
}
|
||||
},
|
||||
|
@ -683,7 +683,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
||||
hir::ItemEnum(..) => "enum",
|
||||
_ => return Some((err_span, err_msg, None))
|
||||
};
|
||||
let msg = format!("{} `{}` is private", desc, item.ident);
|
||||
let msg = format!("{} `{}` is private", desc, item.name);
|
||||
Some((err_span, err_msg, Some((span, msg))))
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||
|
||||
/// Constructs the reduced graph for one item.
|
||||
fn build_reduced_graph_for_item(&mut self, item: &Item, parent: &Rc<Module>) -> Rc<Module> {
|
||||
let name = item.ident.name;
|
||||
let name = item.name;
|
||||
let sp = item.span;
|
||||
let is_public = item.vis == hir::Public;
|
||||
let modifiers = if is_public {
|
||||
@ -539,7 +539,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||
|
||||
// Add the names of all the items to the trait info.
|
||||
for trait_item in items {
|
||||
let name_bindings = self.add_child(trait_item.ident.name,
|
||||
let name_bindings = self.add_child(trait_item.name,
|
||||
&module_parent,
|
||||
ForbidDuplicateTypesAndValues,
|
||||
trait_item.span);
|
||||
@ -563,7 +563,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
self.trait_item_map.insert((trait_item.ident.name, def_id),
|
||||
self.trait_item_map.insert((trait_item.name, def_id),
|
||||
DefId::local(trait_item.id));
|
||||
}
|
||||
|
||||
@ -606,7 +606,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||
fn build_reduced_graph_for_foreign_item(&mut self,
|
||||
foreign_item: &ForeignItem,
|
||||
parent: &Rc<Module>) {
|
||||
let name = foreign_item.ident.name;
|
||||
let name = foreign_item.name;
|
||||
let is_public = foreign_item.vis == hir::Public;
|
||||
let modifiers = if is_public {
|
||||
DefModifiers::PUBLIC
|
||||
|
@ -1258,7 +1258,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
|
||||
fn get_trait_name(&self, did: DefId) -> Name {
|
||||
if did.is_local() {
|
||||
self.ast_map.expect_item(did.node).ident.name
|
||||
self.ast_map.expect_item(did.node).name
|
||||
} else {
|
||||
csearch::get_trait_name(&self.session.cstore, did)
|
||||
}
|
||||
@ -2109,7 +2109,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn resolve_item(&mut self, item: &Item) {
|
||||
let name = item.ident.name;
|
||||
let name = item.name;
|
||||
|
||||
debug!("(resolving item) resolving {}",
|
||||
name);
|
||||
@ -2184,7 +2184,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
});
|
||||
}
|
||||
hir::TypeTraitItem(..) => {
|
||||
this.check_if_primitive_type_name(trait_item.ident.name,
|
||||
this.check_if_primitive_type_name(trait_item.name,
|
||||
trait_item.span);
|
||||
this.with_type_parameter_rib(NoTypeParameters, |this| {
|
||||
visit::walk_trait_item(this, trait_item)
|
||||
@ -2486,7 +2486,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
ConstImplItem(..) => {
|
||||
// If this is a trait impl, ensure the const
|
||||
// exists in trait
|
||||
this.check_trait_item(impl_item.ident.name,
|
||||
this.check_trait_item(impl_item.name,
|
||||
impl_item.span,
|
||||
|n, s| ResolutionError::ConstNotMemberOfTrait(n, s));
|
||||
this.with_constant_rib(|this| {
|
||||
@ -2496,7 +2496,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
MethodImplItem(ref sig, _) => {
|
||||
// If this is a trait impl, ensure the method
|
||||
// exists in trait
|
||||
this.check_trait_item(impl_item.ident.name,
|
||||
this.check_trait_item(impl_item.name,
|
||||
impl_item.span,
|
||||
|n, s| ResolutionError::MethodNotMemberOfTrait(n, s));
|
||||
|
||||
@ -2513,7 +2513,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
TypeImplItem(ref ty) => {
|
||||
// If this is a trait impl, ensure the type
|
||||
// exists in trait
|
||||
this.check_trait_item(impl_item.ident.name,
|
||||
this.check_trait_item(impl_item.name,
|
||||
impl_item.span,
|
||||
|n, s| ResolutionError::TypeNotMemberOfTrait(n, s));
|
||||
|
||||
|
@ -2099,7 +2099,7 @@ pub fn trans_item(ccx: &CrateContext, item: &hir::Item) {
|
||||
}
|
||||
hir::ItemImpl(_, _, ref generics, _, _, ref impl_items) => {
|
||||
meth::trans_impl(ccx,
|
||||
item.ident,
|
||||
item.name,
|
||||
&impl_items[..],
|
||||
generics,
|
||||
item.id);
|
||||
|
@ -1858,8 +1858,8 @@ pub fn create_global_var_metadata(cx: &CrateContext,
|
||||
let (name, span) = match var_item {
|
||||
hir_map::NodeItem(item) => {
|
||||
match item.node {
|
||||
hir::ItemStatic(..) => (item.ident.name, item.span),
|
||||
hir::ItemConst(..) => (item.ident.name, item.span),
|
||||
hir::ItemStatic(..) => (item.name, item.span),
|
||||
hir::ItemConst(..) => (item.name, item.span),
|
||||
_ => {
|
||||
cx.sess()
|
||||
.span_bug(item.span,
|
||||
|
@ -242,7 +242,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
match item.node {
|
||||
hir::ItemFn(ref fn_decl, _, _, _, ref generics, ref top_level_block) => {
|
||||
(item.ident.name, fn_decl, generics, top_level_block, item.span, true)
|
||||
(item.name, fn_decl, generics, top_level_block, item.span, true)
|
||||
}
|
||||
_ => {
|
||||
cx.sess().span_bug(item.span,
|
||||
@ -257,7 +257,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
||||
}
|
||||
|
||||
(impl_item.ident.name,
|
||||
(impl_item.name,
|
||||
&sig.decl,
|
||||
&sig.generics,
|
||||
body,
|
||||
@ -296,7 +296,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
||||
}
|
||||
|
||||
(trait_item.ident.name,
|
||||
(trait_item.name,
|
||||
&sig.decl,
|
||||
&sig.generics,
|
||||
body,
|
||||
|
@ -908,7 +908,7 @@ pub fn link_name(i: &hir::ForeignItem) -> InternedString {
|
||||
Some(ln) => ln.clone(),
|
||||
None => match weak_lang_items::link_name(&i.attrs) {
|
||||
Some(name) => name,
|
||||
None => i.ident.name.as_str(),
|
||||
None => i.name.as_str(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ use syntax::codemap::Span;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
pub fn get_simple_intrinsic(ccx: &CrateContext, item: &hir::ForeignItem) -> Option<ValueRef> {
|
||||
let name = match &*item.ident.name.as_str() {
|
||||
let name = match &*item.name.as_str() {
|
||||
"sqrtf32" => "llvm.sqrt.f32",
|
||||
"sqrtf64" => "llvm.sqrt.f64",
|
||||
"powif32" => "llvm.powi.f32",
|
||||
@ -185,7 +185,7 @@ 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 = foreign_item.ident.name.as_str();
|
||||
let name = foreign_item.name.as_str();
|
||||
|
||||
// For `transmute` we can just trans the input expr directly into dest
|
||||
if name == "transmute" {
|
||||
@ -931,7 +931,8 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
(_, _) => {
|
||||
let intr = match Intrinsic::find(tcx, &name) {
|
||||
Some(intr) => intr,
|
||||
None => ccx.sess().span_bug(foreign_item.span, "unknown intrinsic"),
|
||||
None => ccx.sess().span_bug(foreign_item.span,
|
||||
&format!("unknown intrinsic '{}'", name)),
|
||||
};
|
||||
fn one<T>(x: Vec<T>) -> T {
|
||||
assert_eq!(x.len(), 1);
|
||||
|
@ -53,7 +53,7 @@ const VTABLE_OFFSET: usize = 3;
|
||||
/// be generated once they are invoked with specific type parameters,
|
||||
/// see `trans::base::lval_static_fn()` or `trans::base::monomorphic_fn()`.
|
||||
pub fn trans_impl(ccx: &CrateContext,
|
||||
name: ast::Ident,
|
||||
name: ast::Name,
|
||||
impl_items: &[P<hir::ImplItem>],
|
||||
generics: &hir::Generics,
|
||||
id: ast::NodeId) {
|
||||
|
@ -1313,7 +1313,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
|
||||
match tcx.map.expect_item(trait_did.node).node {
|
||||
hir::ItemTrait(_, _, _, ref trait_items) => {
|
||||
let item = trait_items.iter()
|
||||
.find(|i| i.ident.name == assoc_name)
|
||||
.find(|i| i.name == assoc_name)
|
||||
.expect("missing associated type");
|
||||
DefId::local(item.id)
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &hir::ForeignItem) {
|
||||
}
|
||||
|
||||
let tcx = ccx.tcx;
|
||||
let name = it.ident.name.as_str();
|
||||
let name = it.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");
|
||||
@ -367,7 +367,7 @@ pub fn check_platform_intrinsic_type(ccx: &CrateCtxt,
|
||||
let tcx = ccx.tcx;
|
||||
let i_ty = tcx.lookup_item_type(DefId::local(it.id));
|
||||
let i_n_tps = i_ty.generics.types.len(subst::FnSpace);
|
||||
let name = it.ident.name.as_str();
|
||||
let name = it.name.as_str();
|
||||
|
||||
let (n_tps, inputs, output) = match &*name {
|
||||
"simd_eq" | "simd_ne" | "simd_lt" | "simd_le" | "simd_gt" | "simd_ge" => {
|
||||
|
@ -698,7 +698,7 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
|
||||
}
|
||||
hir::ItemFn(..) => {} // entirely within check_item_body
|
||||
hir::ItemImpl(_, _, _, _, _, ref impl_items) => {
|
||||
debug!("ItemImpl {} with id {}", it.ident, it.id);
|
||||
debug!("ItemImpl {} with id {}", it.name, it.id);
|
||||
match ccx.tcx.impl_trait_ref(DefId::local(it.id)) {
|
||||
Some(impl_trait_ref) => {
|
||||
check_impl_items_against_trait(ccx,
|
||||
@ -761,7 +761,7 @@ pub fn check_item_body<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
|
||||
check_bare_fn(ccx, &**decl, &**body, it.id, it.span, fn_pty.ty, param_env);
|
||||
}
|
||||
hir::ItemImpl(_, _, _, _, _, ref impl_items) => {
|
||||
debug!("ItemImpl {} with id {}", it.ident, it.id);
|
||||
debug!("ItemImpl {} with id {}", it.name, it.id);
|
||||
|
||||
let impl_pty = ccx.tcx.lookup_item_type(DefId::local(it.id));
|
||||
|
||||
@ -845,7 +845,7 @@ fn check_trait_on_unimplemented<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
span_err!(ccx.tcx.sess, attr.span, E0230,
|
||||
"there is no type parameter \
|
||||
{} on trait {}",
|
||||
s, item.ident);
|
||||
s, item.name);
|
||||
}
|
||||
},
|
||||
// `{:1}` and `{}` are not to be used
|
||||
@ -988,7 +988,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
let is_implemented = impl_items.iter().any(|ii| {
|
||||
match ii.node {
|
||||
hir::ConstImplItem(..) => {
|
||||
ii.ident.name == associated_const.name
|
||||
ii.name == associated_const.name
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
@ -1009,7 +1009,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
impl_items.iter().any(|ii| {
|
||||
match ii.node {
|
||||
hir::MethodImplItem(..) => {
|
||||
ii.ident.name == trait_method.name
|
||||
ii.name == trait_method.name
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
@ -1028,7 +1028,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
let is_implemented = impl_items.iter().any(|ii| {
|
||||
match ii.node {
|
||||
hir::TypeImplItem(_) => {
|
||||
ii.ident.name == associated_type.name
|
||||
ii.name == associated_type.name
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
@ -1058,7 +1058,7 @@ 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,
|
||||
invalidator.name,
|
||||
invalidated_items.iter()
|
||||
.map(|name| name.to_string())
|
||||
.collect::<Vec<_>>().join("`, `"))
|
||||
|
@ -149,7 +149,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
|
||||
if let Some(trait_ref) = self.crate_context.tcx.impl_trait_ref(impl_did) {
|
||||
debug!("(checking implementation) adding impl for trait '{:?}', item '{}'",
|
||||
trait_ref,
|
||||
item.ident);
|
||||
item.name);
|
||||
|
||||
enforce_trait_manually_implementable(self.crate_context.tcx,
|
||||
item.span,
|
||||
|
@ -577,7 +577,7 @@ fn convert_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
container: ImplOrTraitItemContainer,
|
||||
sig: &hir::MethodSig,
|
||||
id: ast::NodeId,
|
||||
ident: ast::Ident,
|
||||
name: ast::Name,
|
||||
vis: hir::Visibility,
|
||||
untransformed_rcvr_ty: Ty<'tcx>,
|
||||
rcvr_ty_generics: &ty::Generics<'tcx>,
|
||||
@ -592,7 +592,7 @@ fn convert_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
sig, untransformed_rcvr_ty);
|
||||
|
||||
let def_id = DefId::local(id);
|
||||
let ty_method = ty::Method::new(ident.name,
|
||||
let ty_method = ty::Method::new(name,
|
||||
ty_generics,
|
||||
ty_generic_predicates,
|
||||
fty,
|
||||
@ -605,7 +605,7 @@ fn convert_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
let fty = ccx.tcx.mk_fn(Some(def_id),
|
||||
ccx.tcx.mk_bare_fn(ty_method.fty.clone()));
|
||||
debug!("method {} (id {}) has type {:?}",
|
||||
ident, id, fty);
|
||||
name, id, fty);
|
||||
ccx.tcx.register_item_type(def_id, TypeScheme {
|
||||
generics: ty_method.generics.clone(),
|
||||
ty: fty
|
||||
@ -643,7 +643,7 @@ fn convert_field<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
|
||||
fn convert_associated_const<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
container: ImplOrTraitItemContainer,
|
||||
ident: ast::Ident,
|
||||
name: ast::Name,
|
||||
id: ast::NodeId,
|
||||
vis: hir::Visibility,
|
||||
ty: ty::Ty<'tcx>,
|
||||
@ -656,7 +656,7 @@ fn convert_associated_const<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
let default_id = default.map(|expr| DefId::local(expr.id));
|
||||
|
||||
let associated_const = Rc::new(ty::AssociatedConst {
|
||||
name: ident.name,
|
||||
name: name,
|
||||
vis: vis,
|
||||
def_id: DefId::local(id),
|
||||
container: container,
|
||||
@ -669,13 +669,13 @@ fn convert_associated_const<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
|
||||
fn convert_associated_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
container: ImplOrTraitItemContainer,
|
||||
ident: ast::Ident,
|
||||
name: ast::Name,
|
||||
id: ast::NodeId,
|
||||
vis: hir::Visibility,
|
||||
ty: Option<Ty<'tcx>>)
|
||||
{
|
||||
let associated_type = Rc::new(ty::AssociatedType {
|
||||
name: ident.name,
|
||||
name: name,
|
||||
vis: vis,
|
||||
ty: ty,
|
||||
def_id: DefId::local(id),
|
||||
@ -691,7 +691,7 @@ fn convert_methods<'a,'tcx,'i,I>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
untransformed_rcvr_ty: Ty<'tcx>,
|
||||
rcvr_ty_generics: &ty::Generics<'tcx>,
|
||||
rcvr_ty_predicates: &ty::GenericPredicates<'tcx>)
|
||||
where I: Iterator<Item=(&'i hir::MethodSig, ast::NodeId, ast::Ident, hir::Visibility, Span)>
|
||||
where I: Iterator<Item=(&'i hir::MethodSig, ast::NodeId, ast::Name, hir::Visibility, Span)>
|
||||
{
|
||||
debug!("convert_methods(untransformed_rcvr_ty={:?}, rcvr_ty_generics={:?}, \
|
||||
rcvr_ty_predicates={:?})",
|
||||
@ -743,7 +743,7 @@ fn ensure_no_ty_param_bounds(ccx: &CrateCtxt,
|
||||
|
||||
fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
|
||||
let tcx = ccx.tcx;
|
||||
debug!("convert: item {} with id {}", it.ident, it.id);
|
||||
debug!("convert: item {} with id {}", it.name, it.id);
|
||||
match it.node {
|
||||
// These don't define types.
|
||||
hir::ItemExternCrate(_) | hir::ItemUse(_) |
|
||||
@ -823,7 +823,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
|
||||
hir::TypeImplItem(_) => &mut seen_type_items,
|
||||
_ => &mut seen_value_items,
|
||||
};
|
||||
if !seen_items.insert(impl_item.ident.name) {
|
||||
if !seen_items.insert(impl_item.name) {
|
||||
let desc = match impl_item.node {
|
||||
hir::ConstImplItem(_, _) => "associated constant",
|
||||
hir::TypeImplItem(_) => "associated type",
|
||||
@ -846,7 +846,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
|
||||
ty: ty,
|
||||
});
|
||||
convert_associated_const(ccx, ImplContainer(DefId::local(it.id)),
|
||||
impl_item.ident, impl_item.id,
|
||||
impl_item.name, impl_item.id,
|
||||
impl_item.vis.inherit_from(parent_visibility),
|
||||
ty, Some(&*expr));
|
||||
}
|
||||
@ -863,7 +863,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
|
||||
let typ = ccx.icx(&ty_predicates).to_ty(&ExplicitRscope, ty);
|
||||
|
||||
convert_associated_type(ccx, ImplContainer(DefId::local(it.id)),
|
||||
impl_item.ident, impl_item.id, impl_item.vis,
|
||||
impl_item.name, impl_item.id, impl_item.vis,
|
||||
Some(typ));
|
||||
}
|
||||
}
|
||||
@ -875,7 +875,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
|
||||
// { fn foo(); }` is public, but private in `impl { fn
|
||||
// foo(); }`).
|
||||
let method_vis = ii.vis.inherit_from(parent_visibility);
|
||||
Some((sig, ii.id, ii.ident, method_vis, ii.span))
|
||||
Some((sig, ii.id, ii.name, method_vis, ii.span))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -925,7 +925,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
|
||||
ty: ty,
|
||||
});
|
||||
convert_associated_const(ccx, TraitContainer(DefId::local(it.id)),
|
||||
trait_item.ident, trait_item.id,
|
||||
trait_item.name, trait_item.id,
|
||||
hir::Public, ty, default.as_ref().map(|d| &**d));
|
||||
}
|
||||
_ => {}
|
||||
@ -941,7 +941,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
|
||||
});
|
||||
|
||||
convert_associated_type(ccx, TraitContainer(DefId::local(it.id)),
|
||||
trait_item.ident, trait_item.id, hir::Public,
|
||||
trait_item.name, trait_item.id, hir::Public,
|
||||
typ);
|
||||
}
|
||||
_ => {}
|
||||
@ -953,7 +953,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
|
||||
hir::MethodTraitItem(ref sig, _) => sig,
|
||||
_ => return None,
|
||||
};
|
||||
Some((sig, ti.id, ti.ident, hir::Inherited, ti.span))
|
||||
Some((sig, ti.id, ti.name, hir::Inherited, ti.span))
|
||||
});
|
||||
|
||||
// Run convert_methods on the trait methods.
|
||||
@ -1135,7 +1135,7 @@ fn convert_struct_def<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
tcx.intern_adt_def(
|
||||
did,
|
||||
ty::AdtKind::Struct,
|
||||
vec![convert_struct_variant(tcx, did, it.ident.name, 0, def)]
|
||||
vec![convert_struct_variant(tcx, did, it.name, 0, def)]
|
||||
)
|
||||
}
|
||||
|
||||
@ -1369,7 +1369,7 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
|
||||
let associated_type_names: Vec<_> = items.iter().filter_map(|trait_item| {
|
||||
match trait_item.node {
|
||||
hir::TypeTraitItem(..) => Some(trait_item.ident.name),
|
||||
hir::TypeTraitItem(..) => Some(trait_item.name),
|
||||
_ => None,
|
||||
}
|
||||
}).collect();
|
||||
@ -1444,7 +1444,7 @@ fn trait_defines_associated_type_named(ccx: &CrateCtxt,
|
||||
|
||||
trait_items.iter().any(|trait_item| {
|
||||
match trait_item.node {
|
||||
hir::TypeTraitItem(..) => trait_item.ident.name == assoc_name,
|
||||
hir::TypeTraitItem(..) => trait_item.name == assoc_name,
|
||||
_ => false,
|
||||
}
|
||||
})
|
||||
@ -1511,7 +1511,7 @@ fn convert_trait_predicates<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &hir::Item)
|
||||
};
|
||||
|
||||
let assoc_ty = ccx.tcx.mk_projection(self_trait_ref,
|
||||
trait_item.ident.name);
|
||||
trait_item.name);
|
||||
|
||||
let bounds = compute_bounds(&ccx.icx(&(ast_generics, trait_predicates)),
|
||||
assoc_ty,
|
||||
|
@ -1257,7 +1257,7 @@ impl Clean<Item> for hir::TraitItem {
|
||||
}
|
||||
};
|
||||
Item {
|
||||
name: Some(self.ident.clean(cx)),
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.span.clean(cx),
|
||||
def_id: DefId::local(self.id),
|
||||
@ -1290,7 +1290,7 @@ impl Clean<Item> for hir::ImplItem {
|
||||
}, true),
|
||||
};
|
||||
Item {
|
||||
name: Some(self.ident.clean(cx)),
|
||||
name: Some(self.name.clean(cx)),
|
||||
source: self.span.clean(cx),
|
||||
attrs: self.attrs.clean(cx),
|
||||
def_id: DefId::local(self.id),
|
||||
@ -2484,7 +2484,7 @@ impl Clean<Item> for hir::ForeignItem {
|
||||
}
|
||||
};
|
||||
Item {
|
||||
name: Some(self.ident.clean(cx)),
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
source: self.span.clean(cx),
|
||||
def_id: DefId::local(self.id),
|
||||
|
@ -17,13 +17,13 @@ use syntax;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::abi;
|
||||
use syntax::ast;
|
||||
use syntax::ast::{Ident, NodeId};
|
||||
use syntax::ast::{Ident, Name, NodeId};
|
||||
use syntax::attr;
|
||||
use syntax::ptr::P;
|
||||
use rustc_front::hir;
|
||||
|
||||
pub struct Module {
|
||||
pub name: Option<Ident>,
|
||||
pub name: Option<Name>,
|
||||
pub attrs: Vec<ast::Attribute>,
|
||||
pub where_outer: Span,
|
||||
pub where_inner: Span,
|
||||
@ -48,7 +48,7 @@ pub struct Module {
|
||||
}
|
||||
|
||||
impl Module {
|
||||
pub fn new(name: Option<Ident>) -> Module {
|
||||
pub fn new(name: Option<Name>) -> Module {
|
||||
Module {
|
||||
name : name,
|
||||
id: 0,
|
||||
@ -98,7 +98,7 @@ pub struct Struct {
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub id: NodeId,
|
||||
pub struct_type: StructType,
|
||||
pub name: Ident,
|
||||
pub name: Name,
|
||||
pub generics: hir::Generics,
|
||||
pub attrs: Vec<ast::Attribute>,
|
||||
pub fields: Vec<hir::StructField>,
|
||||
@ -113,7 +113,7 @@ pub struct Enum {
|
||||
pub attrs: Vec<ast::Attribute>,
|
||||
pub id: NodeId,
|
||||
pub whence: Span,
|
||||
pub name: Ident,
|
||||
pub name: Name,
|
||||
}
|
||||
|
||||
pub struct Variant {
|
||||
@ -129,7 +129,7 @@ pub struct Function {
|
||||
pub decl: hir::FnDecl,
|
||||
pub attrs: Vec<ast::Attribute>,
|
||||
pub id: NodeId,
|
||||
pub name: Ident,
|
||||
pub name: Name,
|
||||
pub vis: hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
pub unsafety: hir::Unsafety,
|
||||
@ -142,7 +142,7 @@ pub struct Function {
|
||||
pub struct Typedef {
|
||||
pub ty: P<hir::Ty>,
|
||||
pub gen: hir::Generics,
|
||||
pub name: Ident,
|
||||
pub name: Name,
|
||||
pub id: ast::NodeId,
|
||||
pub attrs: Vec<ast::Attribute>,
|
||||
pub whence: Span,
|
||||
@ -155,7 +155,7 @@ pub struct Static {
|
||||
pub type_: P<hir::Ty>,
|
||||
pub mutability: hir::Mutability,
|
||||
pub expr: P<hir::Expr>,
|
||||
pub name: Ident,
|
||||
pub name: Name,
|
||||
pub attrs: Vec<ast::Attribute>,
|
||||
pub vis: hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
@ -166,7 +166,7 @@ pub struct Static {
|
||||
pub struct Constant {
|
||||
pub type_: P<hir::Ty>,
|
||||
pub expr: P<hir::Expr>,
|
||||
pub name: Ident,
|
||||
pub name: Name,
|
||||
pub attrs: Vec<ast::Attribute>,
|
||||
pub vis: hir::Visibility,
|
||||
pub stab: Option<attr::Stability>,
|
||||
@ -176,7 +176,7 @@ pub struct Constant {
|
||||
|
||||
pub struct Trait {
|
||||
pub unsafety: hir::Unsafety,
|
||||
pub name: Ident,
|
||||
pub name: Name,
|
||||
pub items: Vec<P<hir::TraitItem>>, //should be TraitItem
|
||||
pub generics: hir::Generics,
|
||||
pub bounds: Vec<hir::TyParamBound>,
|
||||
@ -219,7 +219,7 @@ pub struct Macro {
|
||||
}
|
||||
|
||||
pub struct ExternCrate {
|
||||
pub name: Ident,
|
||||
pub name: Name,
|
||||
pub path: Option<String>,
|
||||
pub vis: hir::Visibility,
|
||||
pub attrs: Vec<ast::Attribute>,
|
||||
|
@ -83,7 +83,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn visit_struct_def(&mut self, item: &hir::Item,
|
||||
name: ast::Ident, sd: &hir::StructDef,
|
||||
name: ast::Name, sd: &hir::StructDef,
|
||||
generics: &hir::Generics) -> Struct {
|
||||
debug!("Visiting struct");
|
||||
let struct_type = struct_type_from_def(&*sd);
|
||||
@ -101,7 +101,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn visit_enum_def(&mut self, it: &hir::Item,
|
||||
name: ast::Ident, def: &hir::EnumDef,
|
||||
name: ast::Name, def: &hir::EnumDef,
|
||||
params: &hir::Generics) -> Enum {
|
||||
debug!("Visiting enum");
|
||||
Enum {
|
||||
@ -124,7 +124,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn visit_fn(&mut self, item: &hir::Item,
|
||||
name: ast::Ident, fd: &hir::FnDecl,
|
||||
name: ast::Name, fd: &hir::FnDecl,
|
||||
unsafety: &hir::Unsafety,
|
||||
constness: hir::Constness,
|
||||
abi: &abi::Abi,
|
||||
@ -148,7 +148,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
pub fn visit_mod_contents(&mut self, span: Span, attrs: Vec<ast::Attribute> ,
|
||||
vis: hir::Visibility, id: ast::NodeId,
|
||||
m: &hir::Mod,
|
||||
name: Option<ast::Ident>) -> Module {
|
||||
name: Option<ast::Name>) -> Module {
|
||||
let mut om = Module::new(name);
|
||||
om.where_outer = span;
|
||||
om.where_inner = m.inner;
|
||||
@ -243,7 +243,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
pub fn visit_item(&mut self, item: &hir::Item,
|
||||
renamed: Option<ast::Ident>, om: &mut Module) {
|
||||
debug!("Visiting item {:?}", item);
|
||||
let name = renamed.unwrap_or(item.ident);
|
||||
let name = renamed.map_or(item.name, |x| x.name);
|
||||
match item.node {
|
||||
hir::ItemExternCrate(ref p) => {
|
||||
let path = match *p {
|
||||
|
@ -37,7 +37,7 @@ impl LintPass for Pass {
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
|
||||
match &*it.ident.name.as_str() {
|
||||
match &*it.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'"),
|
||||
_ => {}
|
||||
|
Loading…
Reference in New Issue
Block a user