auto merge of #17683 : gereeter/rust/ident-to-name, r=pcwalton

This does a large chunk of #6993. It is based on top of #17654.
This commit is contained in:
bors 2014-10-23 20:22:18 +00:00
commit 56d544f7ad
22 changed files with 356 additions and 372 deletions

View File

@ -33,7 +33,7 @@ use syntax::parse::token;
use std::collections::hashmap::HashMap;
pub struct StaticMethodInfo {
pub ident: ast::Ident,
pub name: ast::Name,
pub def_id: ast::DefId,
pub fn_style: ast::FnStyle,
pub vis: ast::Visibility,
@ -57,7 +57,7 @@ pub fn each_lang_item(cstore: &cstore::CStore,
pub fn each_child_of_item(cstore: &cstore::CStore,
def_id: ast::DefId,
callback: |decoder::DefLike,
ast::Ident,
ast::Name,
ast::Visibility|) {
let crate_data = cstore.get_crate_data(def_id.krate);
let get_crate_data: decoder::GetCrateDataCb = |cnum| {
@ -74,7 +74,7 @@ pub fn each_child_of_item(cstore: &cstore::CStore,
pub fn each_top_level_item_of_crate(cstore: &cstore::CStore,
cnum: ast::CrateNum,
callback: |decoder::DefLike,
ast::Ident,
ast::Name,
ast::Visibility|) {
let crate_data = cstore.get_crate_data(cnum);
let get_crate_data: decoder::GetCrateDataCb = |cnum| {
@ -139,7 +139,7 @@ pub fn get_impl_or_trait_item(tcx: &ty::ctxt, def: ast::DefId)
}
pub fn get_trait_item_name_and_kind(cstore: &cstore::CStore, def: ast::DefId)
-> (ast::Ident, resolve::TraitItemKind) {
-> (ast::Name, resolve::TraitItemKind) {
let cdata = cstore.get_crate_data(def.krate);
decoder::get_trait_item_name_and_kind(cstore.intr.clone(),
&*cdata,
@ -173,7 +173,7 @@ pub fn get_supertraits(tcx: &ty::ctxt, def: ast::DefId) -> Vec<Rc<ty::TraitRef>>
}
pub fn get_type_name_if_impl(cstore: &cstore::CStore, def: ast::DefId)
-> Option<ast::Ident> {
-> Option<ast::Name> {
let cdata = cstore.get_crate_data(def.krate);
decoder::get_type_name_if_impl(&*cdata, def.node)
}

View File

@ -292,12 +292,12 @@ fn item_path(item_doc: rbml::Doc) -> Vec<ast_map::PathElem> {
result
}
fn item_name(intr: &IdentInterner, item: rbml::Doc) -> ast::Ident {
fn item_name(intr: &IdentInterner, item: rbml::Doc) -> ast::Name {
let name = reader::get_doc(item, tag_paths_data_name);
let string = name.as_str_slice();
match intr.find_equiv(&string) {
None => token::str_to_ident(string),
Some(val) => ast::Ident::new(val),
None => token::intern(string),
Some(val) => val,
}
}
@ -457,7 +457,7 @@ fn each_child_of_item_or_crate(intr: Rc<IdentInterner>,
item_doc: rbml::Doc,
get_crate_data: GetCrateDataCb,
callback: |DefLike,
ast::Ident,
ast::Name,
ast::Visibility|) {
// Iterate over all children.
let _ = reader::tagged_docs(item_doc, tag_mod_child, |child_info_doc| {
@ -579,7 +579,7 @@ fn each_child_of_item_or_crate(intr: Rc<IdentInterner>,
child_def_id.krate);
// These items have a public visibility because they're part of
// a public re-export.
callback(def_like, token::str_to_ident(name), ast::Public);
callback(def_like, token::intern(name), ast::Public);
}
}
@ -592,7 +592,7 @@ pub fn each_child_of_item(intr: Rc<IdentInterner>,
cdata: Cmd,
id: ast::NodeId,
get_crate_data: GetCrateDataCb,
callback: |DefLike, ast::Ident, ast::Visibility|) {
callback: |DefLike, ast::Name, ast::Visibility|) {
// Find the item.
let root_doc = rbml::Doc::new(cdata.data());
let items = reader::get_doc(root_doc, tag_items);
@ -613,7 +613,7 @@ pub fn each_top_level_item_of_crate(intr: Rc<IdentInterner>,
cdata: Cmd,
get_crate_data: GetCrateDataCb,
callback: |DefLike,
ast::Ident,
ast::Name,
ast::Visibility|) {
let root_doc = rbml::Doc::new(cdata.data());
let misc_info_doc = reader::get_doc(root_doc, tag_misc_info);
@ -745,7 +745,7 @@ pub fn get_impl_items(cdata: Cmd, impl_id: ast::NodeId)
pub fn get_trait_item_name_and_kind(intr: Rc<IdentInterner>,
cdata: Cmd,
id: ast::NodeId)
-> (ast::Ident, TraitItemKind) {
-> (ast::Name, TraitItemKind) {
let doc = lookup_item(id, cdata.data());
let name = item_name(&*intr, doc);
match item_sort(doc) {
@ -800,7 +800,7 @@ pub fn get_impl_or_trait_item(intr: Rc<IdentInterner>,
}
't' => {
ty::TypeTraitItem(Rc::new(ty::AssociatedType {
ident: name,
name: name,
vis: vis,
def_id: def_id,
container: container,
@ -885,7 +885,7 @@ pub fn get_supertraits(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
}
pub fn get_type_name_if_impl(cdata: Cmd,
node_id: ast::NodeId) -> Option<ast::Ident> {
node_id: ast::NodeId) -> Option<ast::Name> {
let item = lookup_item(node_id, cdata.data());
if item_family(item) != Impl {
return None;
@ -893,7 +893,7 @@ pub fn get_type_name_if_impl(cdata: Cmd,
let mut ret = None;
reader::tagged_docs(item, tag_item_impl_type_basename, |doc| {
ret = Some(token::str_to_ident(doc.as_str_slice()));
ret = Some(token::intern(doc.as_str_slice()));
false
});
@ -936,7 +936,7 @@ pub fn get_static_methods_if_impl(intr: Rc<IdentInterner>,
}
static_impl_methods.push(StaticMethodInfo {
ident: item_name(&*intr, impl_method_doc),
name: item_name(&*intr, impl_method_doc),
def_id: item_def_id(impl_method_doc, cdata),
fn_style: fn_style,
vis: item_visibility(impl_method_doc),
@ -1005,13 +1005,12 @@ pub fn get_struct_fields(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId)
reader::tagged_docs(item, tag_item_field, |an_item| {
let f = item_family(an_item);
if f == PublicField || f == InheritedField {
// FIXME #6993: name should be of type Name, not Ident
let name = item_name(&*intr, an_item);
let did = item_def_id(an_item, cdata);
let tagdoc = reader::get_doc(an_item, tag_item_field_origin);
let origin_id = translate_def_id(cdata, reader::with_doc_data(tagdoc, parse_def_id));
result.push(ty::field_ty {
name: name.name,
name: name,
id: did,
vis: struct_field_family_to_visibility(f),
origin: origin_id,
@ -1393,7 +1392,7 @@ fn doc_generics(base_doc: rbml::Doc,
reader::tagged_docs(doc, tag_region_param_def, |rp_doc| {
let ident_str_doc = reader::get_doc(rp_doc,
tag_region_param_def_ident);
let ident = item_name(&*token::get_ident_interner(), ident_str_doc);
let name = item_name(&*token::get_ident_interner(), ident_str_doc);
let def_id_doc = reader::get_doc(rp_doc,
tag_region_param_def_def_id);
let def_id = reader::with_doc_data(def_id_doc, parse_def_id);
@ -1414,7 +1413,7 @@ fn doc_generics(base_doc: rbml::Doc,
true
});
regions.push(space, ty::RegionParameterDef { name: ident.name,
regions.push(space, ty::RegionParameterDef { name: name,
def_id: def_id,
space: space,
index: index,

View File

@ -378,9 +378,9 @@ fn encode_path<PI: Iterator<PathElem> + Clone>(rbml_w: &mut Encoder,
fn encode_reexported_static_method(rbml_w: &mut Encoder,
exp: &middle::resolve::Export2,
method_def_id: DefId,
method_ident: Ident) {
method_name: Name) {
debug!("(encode reexported static method) {}::{}",
exp.name, token::get_ident(method_ident));
exp.name, token::get_name(method_name));
rbml_w.start_tag(tag_items_data_item_reexport);
rbml_w.start_tag(tag_items_data_item_reexport_def_id);
rbml_w.wr_str(def_to_string(method_def_id).as_slice());
@ -388,7 +388,7 @@ fn encode_reexported_static_method(rbml_w: &mut Encoder,
rbml_w.start_tag(tag_items_data_item_reexport_name);
rbml_w.wr_str(format!("{}::{}",
exp.name,
token::get_ident(method_ident)).as_slice());
token::get_name(method_name)).as_slice());
rbml_w.end_tag();
rbml_w.end_tag();
}
@ -410,7 +410,7 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext,
encode_reexported_static_method(rbml_w,
exp,
m.def_id,
m.ident);
m.name);
}
ty::TypeTraitItem(_) => {}
}
@ -435,7 +435,7 @@ fn encode_reexported_static_trait_methods(ecx: &EncodeContext,
encode_reexported_static_method(rbml_w,
exp,
m.def_id,
m.ident);
m.name);
}
_ => {}
}
@ -829,7 +829,7 @@ fn encode_method_ty_fields(ecx: &EncodeContext,
rbml_w: &mut Encoder,
method_ty: &ty::Method) {
encode_def_id(rbml_w, method_ty.def_id);
encode_name(rbml_w, method_ty.ident.name);
encode_name(rbml_w, method_ty.name);
encode_generics(rbml_w, ecx, &method_ty.generics,
tag_method_ty_generics);
encode_method_fty(ecx, rbml_w, &method_ty.fty);
@ -854,7 +854,7 @@ fn encode_info_for_method(ecx: &EncodeContext,
ast_item_opt: Option<&ImplItem>) {
debug!("encode_info_for_method: {} {}", m.def_id,
token::get_ident(m.ident));
token::get_name(m.name));
rbml_w.start_tag(tag_items_data_item);
encode_method_ty_fields(ecx, rbml_w, m);
@ -868,7 +868,7 @@ fn encode_info_for_method(ecx: &EncodeContext,
let pty = lookup_item_type(ecx.tcx, m.def_id);
encode_bounds_and_type(rbml_w, ecx, &pty);
let elem = ast_map::PathName(m.ident.name);
let elem = ast_map::PathName(m.name);
encode_path(rbml_w, impl_path.chain(Some(elem).into_iter()));
match ast_item_opt {
Some(&ast::MethodImplItem(ref ast_method)) => {
@ -897,12 +897,12 @@ fn encode_info_for_associated_type(ecx: &EncodeContext,
typedef_opt: Option<P<ast::Typedef>>) {
debug!("encode_info_for_associated_type({},{})",
associated_type.def_id,
token::get_ident(associated_type.ident));
token::get_name(associated_type.name));
rbml_w.start_tag(tag_items_data_item);
encode_def_id(rbml_w, associated_type.def_id);
encode_name(rbml_w, associated_type.ident.name);
encode_name(rbml_w, associated_type.name);
encode_visibility(rbml_w, associated_type.vis);
encode_family(rbml_w, 'y');
encode_parent_item(rbml_w, local_def(parent_id));
@ -911,7 +911,7 @@ fn encode_info_for_associated_type(ecx: &EncodeContext,
let stab = stability::lookup(ecx.tcx, associated_type.def_id);
encode_stability(rbml_w, stab);
let elem = ast_map::PathName(associated_type.ident.name);
let elem = ast_map::PathName(associated_type.name);
encode_path(rbml_w, impl_path.chain(Some(elem).into_iter()));
match typedef_opt {
@ -1395,7 +1395,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_method_ty_fields(ecx, rbml_w, &*method_ty);
let elem = ast_map::PathName(method_ty.ident.name);
let elem = ast_map::PathName(method_ty.name);
encode_path(rbml_w,
path.clone().chain(Some(elem).into_iter()));
@ -1419,7 +1419,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
ty::StaticExplicitSelfCategory;
}
ty::TypeTraitItem(associated_type) => {
let elem = ast_map::PathName(associated_type.ident.name);
let elem = ast_map::PathName(associated_type.name);
encode_path(rbml_w,
path.clone().chain(Some(elem).into_iter()));

View File

@ -96,13 +96,17 @@ fn scan<R>(st: &mut PState, is_last: |char| -> bool, op: |&[u8]| -> R) -> R {
}
pub fn parse_ident(st: &mut PState, last: char) -> ast::Ident {
fn is_last(b: char, c: char) -> bool { return c == b; }
return parse_ident_(st, |a| is_last(last, a) );
ast::Ident::new(parse_name(st, last))
}
fn parse_ident_(st: &mut PState, is_last: |char| -> bool) -> ast::Ident {
pub fn parse_name(st: &mut PState, last: char) -> ast::Name {
fn is_last(b: char, c: char) -> bool { return c == b; }
parse_name_(st, |a| is_last(last, a) )
}
fn parse_name_(st: &mut PState, is_last: |char| -> bool) -> ast::Name {
scan(st, is_last, |bytes| {
token::str_to_ident(str::from_utf8(bytes).unwrap())
token::intern(str::from_utf8(bytes).unwrap())
})
}
@ -625,7 +629,7 @@ pub fn parse_type_param_def_data(data: &[u8], start: uint,
}
fn parse_type_param_def(st: &mut PState, conv: conv_did) -> ty::TypeParameterDef {
let ident = parse_ident(st, ':');
let name = parse_name(st, ':');
let def_id = parse_def(st, NominalType, |x,y| conv(x,y));
let space = parse_param_space(st);
assert_eq!(next(st), '|');
@ -639,7 +643,7 @@ fn parse_type_param_def(st: &mut PState, conv: conv_did) -> ty::TypeParameterDef
let default = parse_opt(st, |st| parse_ty(st, |x,y| conv(x,y)));
ty::TypeParameterDef {
ident: ident,
name: name,
def_id: def_id,
space: space,
index: index,

View File

@ -383,7 +383,7 @@ pub fn enc_bounds(w: &mut SeekableMemWriter, cx: &ctxt, bs: &ty::ParamBounds) {
pub fn enc_type_param_def(w: &mut SeekableMemWriter, cx: &ctxt, v: &ty::TypeParameterDef) {
mywrite!(w, "{}:{}|{}|{}|",
token::get_ident(v.ident), (cx.ds)(v.def_id),
token::get_name(v.name), (cx.ds)(v.def_id),
v.space.to_uint(), v.index);
enc_opt(w, v.associated_with, |w, did| mywrite!(w, "{}", (cx.ds)(did)));
mywrite!(w, "|");

View File

@ -670,7 +670,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,TYPER> {
if !contains_field_named(with_field, fields) {
let cmt_field = self.mc.cat_field(&*with_expr,
with_cmt.clone(),
with_field.ident,
with_field.name,
with_field.mt.ty);
self.delegate_consume(with_expr.id, with_expr.span, cmt_field);
}
@ -681,7 +681,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,TYPER> {
-> bool
{
fields.iter().any(
|f| f.ident.node.name == field.ident.name)
|f| f.ident.node.name == field.name)
}
}

View File

@ -472,7 +472,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
expr.id,
expr.repr(self.tcx()),
base_cmt.repr(self.tcx()));
Ok(self.cat_field(expr, base_cmt, f_name.node, expr_ty))
Ok(self.cat_field(expr, base_cmt, f_name.node.name, expr_ty))
}
ast::ExprTupField(ref base, idx, _) => {
@ -820,14 +820,14 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
pub fn cat_field<N:ast_node>(&self,
node: &N,
base_cmt: cmt,
f_name: ast::Ident,
f_name: ast::Name,
f_ty: ty::t)
-> cmt {
Rc::new(cmt_ {
id: node.id(),
span: node.span(),
mutbl: base_cmt.mutbl.inherit(),
cat: cat_interior(base_cmt, InteriorField(NamedField(f_name.name))),
cat: cat_interior(base_cmt, InteriorField(NamedField(f_name))),
ty: f_ty,
note: NoteNone
})
@ -1223,7 +1223,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
// {f1: p1, ..., fN: pN}
for fp in field_pats.iter() {
let field_ty = if_ok!(self.pat_ty(&*fp.pat)); // see (*2)
let cmt_field = self.cat_field(pat, cmt.clone(), fp.ident, field_ty);
let cmt_field = self.cat_field(pat, cmt.clone(), fp.ident.name, field_ty);
if_ok!(self.cat_pattern(cmt_field, &*fp.pat, |x,y,z| op(x,y,z)));
}
}

File diff suppressed because it is too large Load Diff

View File

@ -794,7 +794,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
def_id)
.iter()
.find(|mr| {
mr.ident().name == ti.ident().name
mr.name() == ti.name()
})
.unwrap()
.def_id())
@ -807,10 +807,10 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
Some((*impl_items)[def_id]
.iter()
.find(|mr| {
ty::impl_or_trait_item(
&self.analysis.ty_cx,
mr.def_id()).ident().name ==
ti.ident().name
ty::impl_or_trait_item(
&self.analysis.ty_cx,
mr.def_id()
).name() == ti.name()
})
.unwrap()
.def_id())

View File

@ -59,7 +59,7 @@ fn type_is_newtype_immediate(ccx: &CrateContext, ty: ty::t) -> bool {
ty::ty_struct(def_id, ref substs) => {
let fields = ty::struct_fields(ccx.tcx(), def_id, substs);
fields.len() == 1 &&
fields[0].ident.name ==
fields[0].name ==
token::special_idents::unnamed_field.name &&
type_is_immediate(ccx, fields[0].mt.ty)
}

View File

@ -585,7 +585,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
expr::with_field_tys(tcx, ety, Some(e.id), |discr, field_tys| {
let cs = field_tys.iter().enumerate()
.map(|(ix, &field_ty)| {
match fs.iter().find(|f| field_ty.ident.name == f.ident.node.name) {
match fs.iter().find(|f| field_ty.name == f.ident.node.name) {
Some(ref f) => const_expr(cx, &*f.expr).val0(),
None => {
match base_val {

View File

@ -1931,10 +1931,10 @@ impl StructMemberDescriptionFactory {
};
self.fields.iter().enumerate().map(|(i, field)| {
let name = if field.ident.name == special_idents::unnamed_field.name {
let name = if field.name == special_idents::unnamed_field.name {
"".to_string()
} else {
token::get_ident(field.ident).get().to_string()
token::get_name(field.name).get().to_string()
};
let offset = if self.is_simd {
@ -2142,8 +2142,7 @@ impl EnumMemberDescriptionFactory {
// First create a description of the artificial wrapper struct:
let non_null_variant = &(*self.variants)[non_null_variant_index as uint];
let non_null_variant_ident = non_null_variant.name;
let non_null_variant_name = token::get_ident(non_null_variant_ident);
let non_null_variant_name = token::get_name(non_null_variant.name);
// The llvm type and metadata of the pointer
let non_null_llvm_type = type_of::type_of(cx, nnty);
@ -2188,8 +2187,7 @@ impl EnumMemberDescriptionFactory {
// Encode the information about the null variant in the union
// member's name.
let null_variant_index = (1 - non_null_variant_index) as uint;
let null_variant_ident = (*self.variants)[null_variant_index].name;
let null_variant_name = token::get_ident(null_variant_ident);
let null_variant_name = token::get_name((*self.variants)[null_variant_index].name);
let union_member_name = format!("RUST$ENCODED$ENUM${}${}",
0u,
null_variant_name);
@ -2230,8 +2228,7 @@ impl EnumMemberDescriptionFactory {
// Encode the information about the null variant in the union
// member's name.
let null_variant_index = (1 - nndiscr) as uint;
let null_variant_ident = (*self.variants)[null_variant_index].name;
let null_variant_name = token::get_ident(null_variant_ident);
let null_variant_name = token::get_name((*self.variants)[null_variant_index].name);
let discrfield = match ptrfield {
adt::ThinPointer(field) => format!("{}", field),
adt::FatPointer(field, pair) => format!("{}${}", field, pair)
@ -2307,7 +2304,7 @@ fn describe_enum_variant(cx: &CrateContext,
struct_def.packed);
// Could do some consistency checks here: size, align, field count, discr type
let variant_name = token::get_ident(variant_info.name);
let variant_name = token::get_name(variant_info.name);
let variant_name = variant_name.get();
let unique_type_id = debug_context(cx).type_map
.borrow_mut()
@ -2377,7 +2374,7 @@ fn prepare_enum_metadata(cx: &CrateContext,
let enumerators_metadata: Vec<DIDescriptor> = variants
.iter()
.map(|v| {
token::get_ident(v.name).get().with_c_str(|name| {
token::get_name(v.name).get().with_c_str(|name| {
unsafe {
llvm::LLVMDIBuilderCreateEnumerator(
DIB(cx),

View File

@ -1328,7 +1328,7 @@ fn trans_struct<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let numbered_fields = fields.iter().map(|field| {
let opt_pos =
field_tys.iter().position(|field_ty|
field_ty.ident.name == field.ident.node.name);
field_ty.name == field.ident.node.name);
match opt_pos {
Some(i) => {
*need_base.get_mut(i) = false;

View File

@ -300,10 +300,7 @@ fn method_with_name(ccx: &CrateContext, impl_id: ast::DefId, name: ast::Name)
.expect("could not find impl while translating");
let meth_did = impl_items.iter()
.find(|&did| {
ty::impl_or_trait_item(ccx.tcx(),
did.def_id()).ident()
.name ==
name
ty::impl_or_trait_item(ccx.tcx(), did.def_id()).name() == name
}).expect("could not find method while \
translating");
@ -324,13 +321,13 @@ fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let ccx = bcx.ccx();
let impl_did = vtable_impl.impl_def_id;
let mname = match ty::trait_item(ccx.tcx(), trait_id, n_method) {
ty::MethodTraitItem(method) => method.ident,
ty::MethodTraitItem(method) => method.name,
ty::TypeTraitItem(_) => {
bcx.tcx().sess.bug("can't monomorphize an associated \
type")
}
};
let mth_id = method_with_name(bcx.ccx(), impl_did, mname.name);
let mth_id = method_with_name(bcx.ccx(), impl_did, mname);
// create a concatenated set of substitutions which includes
// those from the impl and those from the method:
@ -703,10 +700,10 @@ fn emit_vtable_methods(bcx: Block,
let trait_item_def_ids = ty::trait_item_def_ids(tcx, trt_id);
trait_item_def_ids.iter().flat_map(|method_def_id| {
let method_def_id = method_def_id.def_id();
let ident = ty::impl_or_trait_item(tcx, method_def_id).ident();
let name = ty::impl_or_trait_item(tcx, method_def_id).name();
// The substitutions we have are on the impl, so we grab
// the method type from the impl to substitute into.
let m_id = method_with_name(ccx, impl_id, ident.name);
let m_id = method_with_name(ccx, impl_id, name);
let ti = ty::impl_or_trait_item(tcx, m_id);
match ti {
ty::MethodTraitItem(m) => {
@ -717,7 +714,7 @@ fn emit_vtable_methods(bcx: Block,
ty::type_has_self(ty::mk_bare_fn(tcx, m.fty.clone())) {
debug!("(making impl vtable) method has self or type \
params: {}",
token::get_ident(ident));
token::get_name(name));
Some(C_null(Type::nil(ccx).ptr_to())).into_iter()
} else {
let mut fn_ref = trans_fn_ref_with_substs(

View File

@ -65,7 +65,7 @@ pub const INITIAL_DISCRIMINANT_VALUE: Disr = 0;
#[deriving(PartialEq, Eq, Hash)]
pub struct field {
pub ident: ast::Ident,
pub name: ast::Name,
pub mt: mt
}
@ -107,10 +107,10 @@ impl ImplOrTraitItem {
}
}
pub fn ident(&self) -> ast::Ident {
pub fn name(&self) -> ast::Name {
match *self {
MethodTraitItem(ref method) => method.ident,
TypeTraitItem(ref associated_type) => associated_type.ident,
MethodTraitItem(ref method) => method.name,
TypeTraitItem(ref associated_type) => associated_type.name,
}
}
@ -146,7 +146,7 @@ impl ImplOrTraitItemId {
#[deriving(Clone, Show)]
pub struct Method {
pub ident: ast::Ident,
pub name: ast::Name,
pub generics: ty::Generics,
pub fty: BareFnTy,
pub explicit_self: ExplicitSelfCategory,
@ -159,7 +159,7 @@ pub struct Method {
}
impl Method {
pub fn new(ident: ast::Ident,
pub fn new(name: ast::Name,
generics: ty::Generics,
fty: BareFnTy,
explicit_self: ExplicitSelfCategory,
@ -169,7 +169,7 @@ impl Method {
provided_source: Option<ast::DefId>)
-> Method {
Method {
ident: ident,
name: name,
generics: generics,
fty: fty,
explicit_self: explicit_self,
@ -190,7 +190,7 @@ impl Method {
#[deriving(Clone)]
pub struct AssociatedType {
pub ident: ast::Ident,
pub name: ast::Name,
pub vis: ast::Visibility,
pub def_id: ast::DefId,
pub container: ImplOrTraitItemContainer,
@ -1205,7 +1205,7 @@ impl fmt::Show for IntVarValue {
#[deriving(Clone, Show)]
pub struct TypeParameterDef {
pub ident: ast::Ident,
pub name: ast::Name,
pub def_id: ast::DefId,
pub space: subst::ParamSpace,
pub index: uint,
@ -3746,18 +3746,18 @@ pub fn stmt_node_id(s: &ast::Stmt) -> ast::NodeId {
pub fn field_idx_strict(tcx: &ctxt, name: ast::Name, fields: &[field])
-> uint {
let mut i = 0u;
for f in fields.iter() { if f.ident.name == name { return i; } i += 1u; }
for f in fields.iter() { if f.name == name { return i; } i += 1u; }
tcx.sess.bug(format!(
"no field named `{}` found in the list of fields `{}`",
token::get_name(name),
fields.iter()
.map(|f| token::get_ident(f.ident).get().to_string())
.map(|f| token::get_name(f.name).get().to_string())
.collect::<Vec<String>>()).as_slice());
}
pub fn impl_or_trait_item_idx(id: ast::Ident, trait_items: &[ImplOrTraitItem])
pub fn impl_or_trait_item_idx(id: ast::Name, trait_items: &[ImplOrTraitItem])
-> Option<uint> {
trait_items.iter().position(|m| m.ident() == id)
trait_items.iter().position(|m| m.name() == id)
}
pub fn ty_sort_string(cx: &ctxt, t: t) -> String {
@ -4119,7 +4119,7 @@ pub fn associated_type_parameter_index(cx: &ctxt,
pub struct AssociatedTypeInfo {
pub def_id: ast::DefId,
pub index: uint,
pub ident: ast::Ident,
pub name: ast::Name,
}
impl PartialOrd for AssociatedTypeInfo {
@ -4222,7 +4222,7 @@ pub struct VariantInfo {
pub args: Vec<t>,
pub arg_names: Option<Vec<ast::Ident> >,
pub ctor_ty: t,
pub name: ast::Ident,
pub name: ast::Name,
pub id: ast::DefId,
pub disr_val: Disr,
pub vis: Visibility
@ -4250,7 +4250,7 @@ impl VariantInfo {
args: arg_tys,
arg_names: None,
ctor_ty: ctor_ty,
name: ast_variant.node.name,
name: ast_variant.node.name.name,
id: ast_util::local_def(ast_variant.node.id),
disr_val: discriminant,
vis: ast_variant.node.vis
@ -4275,7 +4275,7 @@ impl VariantInfo {
args: arg_tys,
arg_names: Some(arg_names),
ctor_ty: ctor_ty,
name: ast_variant.node.name,
name: ast_variant.node.name.name,
id: ast_util::local_def(ast_variant.node.id),
disr_val: discriminant,
vis: ast_variant.node.vis
@ -4578,8 +4578,7 @@ pub fn struct_fields(cx: &ctxt, did: ast::DefId, substs: &Substs)
-> Vec<field> {
lookup_struct_fields(cx, did).iter().map(|f| {
field {
// FIXME #6993: change type of field to Name and get rid of new()
ident: ast::Ident::new(f.name),
name: f.name,
mt: mt {
ty: lookup_field_type(cx, did, f.id, substs),
mutbl: MutImmutable
@ -4593,8 +4592,7 @@ pub fn struct_fields(cx: &ctxt, did: ast::DefId, substs: &Substs)
pub fn tup_fields(v: &[t]) -> Vec<field> {
v.iter().enumerate().map(|(i, &f)| {
field {
// FIXME #6993: change type of field to Name and get rid of new()
ident: ast::Ident::new(token::intern(i.to_string().as_slice())),
name: token::intern(i.to_string().as_slice()),
mt: mt {
ty: f,
mutbl: MutImmutable
@ -5084,12 +5082,12 @@ pub fn trait_item_of_item(tcx: &ctxt, def_id: ast::DefId)
Some(m) => m.clone(),
None => return None,
};
let name = impl_item.ident().name;
let name = impl_item.name();
match trait_of_item(tcx, def_id) {
Some(trait_did) => {
let trait_items = ty::trait_items(tcx, trait_did);
trait_items.iter()
.position(|m| m.ident().name == name)
.position(|m| m.name() == name)
.map(|idx| ty::trait_item(tcx, trait_did, idx).id())
}
None => None

View File

@ -324,7 +324,7 @@ impl TypeFoldable for ty::ParamBounds {
impl TypeFoldable for ty::TypeParameterDef {
fn fold_with<'tcx, F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::TypeParameterDef {
ty::TypeParameterDef {
ident: self.ident,
name: self.name,
def_id: self.def_id,
space: self.space,
index: self.index,

View File

@ -543,7 +543,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
ty::trait_items(self.tcx(), trait_def_id);
let matching_index =
trait_items.iter()
.position(|item| item.ident().name == self.m_name);
.position(|item| item.name() == self.m_name);
let matching_index = match matching_index {
Some(i) => i,
None => { return; }
@ -1700,7 +1700,7 @@ fn trait_method(tcx: &ty::ctxt,
trait_items
.iter()
.enumerate()
.find(|&(_, ref item)| item.ident().name == method_name)
.find(|&(_, ref item)| item.name() == method_name)
.and_then(|(idx, item)| item.as_opt_method().map(|m| (idx, m)))
}
@ -1714,7 +1714,7 @@ fn impl_method(tcx: &ty::ctxt,
impl_items
.iter()
.map(|&did| ty::impl_or_trait_item(tcx, did.def_id()))
.find(|m| m.ident().name == method_name)
.find(|m| m.name() == method_name)
.and_then(|item| item.as_opt_method())
}

View File

@ -761,8 +761,7 @@ fn check_impl_items_against_trait(ccx: &CrateCtxt,
let opt_trait_method_ty =
trait_items.iter()
.find(|ti| {
ti.ident().name == impl_item_ty.ident()
.name
ti.name() == impl_item_ty.name()
});
match opt_trait_method_ty {
Some(trait_method_ty) => {
@ -784,8 +783,8 @@ fn check_impl_items_against_trait(ccx: &CrateCtxt,
format!("item `{}` is of a \
different kind from \
its trait `{}`",
token::get_ident(
impl_item_ty.ident()),
token::get_name(
impl_item_ty.name()),
pprust::path_to_string(
&ast_trait_ref.path))
.as_slice());
@ -799,7 +798,7 @@ fn check_impl_items_against_trait(ccx: &CrateCtxt,
impl_method.span,
format!(
"method `{}` is not a member of trait `{}`",
token::get_ident(impl_item_ty.ident()),
token::get_name(impl_item_ty.name()),
pprust::path_to_string(
&ast_trait_ref.path)).as_slice());
}
@ -815,7 +814,7 @@ fn check_impl_items_against_trait(ccx: &CrateCtxt,
let opt_associated_type =
trait_items.iter()
.find(|ti| {
ti.ident().name == typedef_ty.ident().name
ti.name() == typedef_ty.name()
});
match opt_associated_type {
Some(associated_type) => {
@ -830,8 +829,8 @@ fn check_impl_items_against_trait(ccx: &CrateCtxt,
format!("item `{}` is of a \
different kind from \
its trait `{}`",
token::get_ident(
typedef_ty.ident()),
token::get_name(
typedef_ty.name()),
pprust::path_to_string(
&ast_trait_ref.path))
.as_slice());
@ -846,7 +845,7 @@ fn check_impl_items_against_trait(ccx: &CrateCtxt,
format!(
"associated type `{}` is not a member of \
trait `{}`",
token::get_ident(typedef_ty.ident()),
token::get_name(typedef_ty.name()),
pprust::path_to_string(
&ast_trait_ref.path)).as_slice());
}
@ -866,33 +865,29 @@ fn check_impl_items_against_trait(ccx: &CrateCtxt,
impl_items.iter().any(|ii| {
match *ii {
ast::MethodImplItem(ref m) => {
m.pe_ident().name == trait_method.ident.name
m.pe_ident().name == trait_method.name
}
ast::TypeImplItem(_) => false,
}
});
let is_provided =
provided_methods.iter().any(
|m| m.ident.name == trait_method.ident.name);
|m| m.name == trait_method.name);
if !is_implemented && !is_provided {
missing_methods.push(
format!("`{}`",
token::get_ident(trait_method.ident)));
missing_methods.push(format!("`{}`", token::get_name(trait_method.name)));
}
}
ty::TypeTraitItem(ref associated_type) => {
let is_implemented = impl_items.iter().any(|ii| {
match *ii {
ast::TypeImplItem(ref typedef) => {
typedef.ident.name == associated_type.ident.name
typedef.ident.name == associated_type.name
}
ast::MethodImplItem(_) => false,
}
});
if !is_implemented {
missing_methods.push(
format!("`{}`",
token::get_ident(associated_type.ident)));
missing_methods.push(format!("`{}`", token::get_name(associated_type.name)));
}
}
}
@ -943,7 +938,7 @@ fn compare_impl_method(tcx: &ty::ctxt,
impl_m_span,
format!("method `{}` has a `{}` declaration in the impl, \
but not in the trait",
token::get_ident(trait_m.ident),
token::get_name(trait_m.name),
ppaux::explicit_self_category_to_str(
&impl_m.explicit_self)).as_slice());
return;
@ -953,7 +948,7 @@ fn compare_impl_method(tcx: &ty::ctxt,
impl_m_span,
format!("method `{}` has a `{}` declaration in the trait, \
but not in the impl",
token::get_ident(trait_m.ident),
token::get_name(trait_m.name),
ppaux::explicit_self_category_to_str(
&trait_m.explicit_self)).as_slice());
return;
@ -969,7 +964,7 @@ fn compare_impl_method(tcx: &ty::ctxt,
span_err!(tcx.sess, impl_m_span, E0049,
"method `{}` has {} type parameter{} \
but its trait declaration has {} type parameter{}",
token::get_ident(trait_m.ident),
token::get_name(trait_m.name),
num_impl_m_type_params,
if num_impl_m_type_params == 1 {""} else {"s"},
num_trait_m_type_params,
@ -981,7 +976,7 @@ fn compare_impl_method(tcx: &ty::ctxt,
span_err!(tcx.sess, impl_m_span, E0050,
"method `{}` has {} parameter{} \
but the declaration in trait `{}` has {}",
token::get_ident(trait_m.ident),
token::get_name(trait_m.name),
impl_m.fty.sig.inputs.len(),
if impl_m.fty.sig.inputs.len() == 1 {""} else {"s"},
ty::item_path_str(tcx, trait_m.def_id),
@ -1082,7 +1077,7 @@ fn compare_impl_method(tcx: &ty::ctxt,
"in method `{}`, type parameter {} requires `{}`, \
which is not required by the corresponding type parameter \
in the trait declaration",
token::get_ident(trait_m.ident),
token::get_name(trait_m.name),
i,
extra_bounds.user_string(tcx));
return;
@ -1121,7 +1116,7 @@ fn compare_impl_method(tcx: &ty::ctxt,
span_err!(tcx.sess, impl_m_span, E0052,
"in method `{}`, type parameter {} requires bound `{}`, which is not \
required by the corresponding type parameter in the trait declaration",
token::get_ident(trait_m.ident),
token::get_name(trait_m.name),
i,
ppaux::trait_ref_to_string(tcx, &*impl_trait_bound));
}
@ -1152,7 +1147,7 @@ fn compare_impl_method(tcx: &ty::ctxt,
Err(ref terr) => {
span_err!(tcx.sess, impl_m_span, E0053,
"method `{}` has an incompatible type for trait: {}",
token::get_ident(trait_m.ident),
token::get_name(trait_m.name),
ty::type_err_to_str(tcx, terr));
ty::note_and_explain_type_err(tcx, terr);
}
@ -1228,7 +1223,7 @@ fn compare_impl_method(tcx: &ty::ctxt,
span,
format!("lifetime parameters or bounds on method `{}` do \
not match the trait declaration",
token::get_ident(impl_m.ident)).as_slice());
token::get_name(impl_m.name)).as_slice());
return false;
}
@ -3836,8 +3831,8 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
ty::ty_struct(did, ref substs) => {
let fields = ty::struct_fields(fcx.tcx(), did, substs);
fields.len() == 1
&& fields[0].ident ==
token::special_idents::unnamed_field
&& fields[0].name ==
token::special_idents::unnamed_field.name
}
_ => false
};

View File

@ -539,7 +539,7 @@ fn subst_receiver_types_in_method_ty(tcx: &ty::ctxt,
method.fty.repr(tcx));
ty::Method::new(
method.ident,
method.name,
method_generics,
method_fty,
method.explicit_self,

View File

@ -279,7 +279,7 @@ fn collect_trait_methods(ccx: &CrateCtxt,
&trait_def.generics,
trait_items.as_slice(),
&m.id,
&m.ident,
&m.ident.name,
&m.explicit_self,
m.abi,
&m.generics,
@ -293,7 +293,7 @@ fn collect_trait_methods(ccx: &CrateCtxt,
&trait_def.generics,
trait_items.as_slice(),
&m.id,
&m.pe_ident(),
&m.pe_ident().name,
m.pe_explicit_self(),
m.pe_abi(),
m.pe_generics(),
@ -318,7 +318,7 @@ fn collect_trait_methods(ccx: &CrateCtxt,
ast::TypeTraitItem(ref ast_associated_type) => {
let trait_did = local_def(trait_id);
let associated_type = ty::AssociatedType {
ident: ast_associated_type.ident,
name: ast_associated_type.ident.name,
vis: ast::Public,
def_id: local_def(ast_associated_type.id),
container: TraitContainer(trait_did),
@ -376,7 +376,7 @@ fn collect_trait_methods(ccx: &CrateCtxt,
trait_generics: &ty::Generics,
trait_items: &[ast::TraitItem],
m_id: &ast::NodeId,
m_ident: &ast::Ident,
m_name: &ast::Name,
m_explicit_self: &ast::ExplicitSelf,
m_abi: abi::Abi,
m_generics: &ast::Generics,
@ -409,7 +409,7 @@ fn collect_trait_methods(ccx: &CrateCtxt,
};
ty::Method::new(
*m_ident,
*m_name,
ty_generics,
fty,
explicit_self_category,
@ -489,7 +489,7 @@ fn convert_associated_type(ccx: &CrateCtxt,
write_ty_to_tcx(ccx.tcx, associated_type.id, param_type);
let associated_type = Rc::new(ty::AssociatedType {
ident: associated_type.ident,
name: associated_type.ident.name,
vis: ast::Public,
def_id: local_def(associated_type.id),
container: TraitContainer(trait_def.trait_ref.def_id),
@ -629,7 +629,7 @@ fn convert_methods<'a,I>(ccx: &CrateCtxt,
// foo(); }`).
let method_vis = m.pe_vis().inherit_from(rcvr_visibility);
ty::Method::new(m.pe_ident(),
ty::Method::new(m.pe_ident().name,
m_ty_generics,
fty,
explicit_self_category,
@ -806,10 +806,8 @@ impl<'a,'tcx> AstConv<'tcx> for ImplCtxt<'a,'tcx> {
match *impl_item {
ast::MethodImplItem(_) => {}
ast::TypeImplItem(ref typedef) => {
if associated_type.ident().name == typedef.ident
.name {
return self.ccx.to_ty(&ExplicitRscope,
&*typedef.typ)
if associated_type.name() == typedef.ident.name {
return self.ccx.to_ty(&ExplicitRscope, &*typedef.typ)
}
}
}
@ -1145,7 +1143,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::Item) {
write_ty_to_tcx(ccx.tcx, typedef.id, typ);
let associated_type = Rc::new(ty::AssociatedType {
ident: typedef.ident,
name: typedef.ident.name,
vis: typedef.vis,
def_id: local_def(typedef.id),
container: ty::ImplContainer(local_def(it.id)),
@ -1685,7 +1683,7 @@ fn ty_generics_for_trait(ccx: &CrateCtxt,
let def = ty::TypeParameterDef {
space: subst::TypeSpace,
index: generics.types.len(subst::TypeSpace),
ident: associated_type.ident,
name: associated_type.ident.name,
def_id: local_def(associated_type.id),
bounds: ty::ParamBounds {
builtin_bounds: ty::empty_builtin_bounds(),
@ -1716,7 +1714,7 @@ fn ty_generics_for_trait(ccx: &CrateCtxt,
let def = ty::TypeParameterDef {
space: subst::SelfSpace,
index: 0,
ident: special_idents::type_self,
name: special_idents::type_self.name,
def_id: local_def(param_id),
bounds: ty::ParamBounds {
region_bounds: vec!(),
@ -1817,7 +1815,7 @@ fn ensure_associated_types<'tcx,AC>(this: &AC, trait_id: ast::DefId)
let info = ty::AssociatedTypeInfo {
def_id: local_def(associated_type.id),
index: index,
ident: associated_type.ident,
name: associated_type.ident.name,
};
result.push(info);
index += 1;
@ -1855,7 +1853,7 @@ fn ensure_associated_types<'tcx,AC>(this: &AC, trait_id: ast::DefId)
let info = ty::AssociatedTypeInfo {
def_id: associated_type.def_id,
index: index,
ident: associated_type.ident
name: associated_type.name
};
result.push(info);
index += 1;
@ -1920,10 +1918,8 @@ fn ty_generics<'tcx,AC>(this: &AC,
this.tcx(),
associated_type_info.def_id);
let def = ty::TypeParameterDef {
ident: associated_type_trait_item
.ident(),
def_id:
associated_type_info.def_id,
name: associated_type_trait_item.name(),
def_id: associated_type_info.def_id,
space: space,
index: types.len() + index,
bounds: ty::ParamBounds {
@ -2033,7 +2029,7 @@ fn ty_generics<'tcx,AC>(this: &AC,
let def = ty::TypeParameterDef {
space: space,
index: index,
ident: param.ident,
name: param.ident.name,
def_id: local_def(param.id),
associated_with: None,
bounds: bounds,

View File

@ -891,9 +891,9 @@ impl Repr for ty::Variance {
impl Repr for ty::Method {
fn repr(&self, tcx: &ctxt) -> String {
format!("method(ident: {}, generics: {}, fty: {}, \
format!("method(name: {}, generics: {}, fty: {}, \
explicit_self: {}, vis: {}, def_id: {})",
self.ident.repr(tcx),
self.name.repr(tcx),
self.generics.repr(tcx),
self.fty.repr(tcx),
self.explicit_self.repr(tcx),
@ -1214,7 +1214,7 @@ impl UserString for ParamTy {
let id = self.idx;
let did = self.def_id;
let ident = match tcx.ty_param_defs.borrow().find(&did.node) {
Some(def) => token::get_ident(def.ident).get().to_string(),
Some(def) => token::get_name(def.name).get().to_string(),
// This can only happen when a type mismatch error happens and
// the actual type has more type parameters than the expected one.

View File

@ -463,10 +463,9 @@ impl Clean<TyParam> for ast::TyParam {
impl Clean<TyParam> for ty::TypeParameterDef {
fn clean(&self, cx: &DocContext) -> TyParam {
cx.external_typarams.borrow_mut().as_mut().unwrap()
.insert(self.def_id, self.ident.clean(cx));
.insert(self.def_id, self.name.clean(cx));
TyParam {
name: self.ident.clean(cx),
name: self.name.clean(cx),
did: self.def_id,
bounds: self.bounds.clean(cx),
default: self.default.clean(cx)
@ -1056,7 +1055,7 @@ impl Clean<Item> for ty::Method {
};
Item {
name: Some(self.ident.clean(cx)),
name: Some(self.name.clean(cx)),
visibility: Some(ast::Inherited),
stability: get_stability(cx, self.def_id),
def_id: self.def_id,
@ -2211,7 +2210,7 @@ impl Clean<Item> for ty::AssociatedType {
fn clean(&self, cx: &DocContext) -> Item {
Item {
source: DUMMY_SP.clean(cx),
name: Some(self.ident.clean(cx)),
name: Some(self.name.clean(cx)),
attrs: Vec::new(),
inner: AssociatedTypeItem,
visibility: None,