Skip to content

Part of #6993: Move a bunch of uses of Ident to Name #17683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/librustc/metadata/csearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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| {
Expand All @@ -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| {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
Expand Down
31 changes: 15 additions & 16 deletions src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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| {
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -885,15 +885,15 @@ 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;
}

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
});

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand Down
26 changes: 13 additions & 13 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,17 @@ 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());
rbml_w.end_tag();
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();
}
Expand All @@ -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(_) => {}
}
Expand All @@ -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);
}
_ => {}
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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)) => {
Expand Down Expand Up @@ -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));
Expand All @@ -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 {
Expand Down Expand Up @@ -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()));

Expand All @@ -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()));

Expand Down
14 changes: 9 additions & 5 deletions src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
ast::Ident::new(parse_name(st, last))
}

pub fn parse_name(st: &mut PState, last: char) -> ast::Name {
fn is_last(b: char, c: char) -> bool { return c == b; }
return parse_ident_(st, |a| is_last(last, a) );
parse_name_(st, |a| is_last(last, a) )
}

fn parse_ident_(st: &mut PState, is_last: |char| -> bool) -> ast::Ident {
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())
})
}

Expand Down Expand Up @@ -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), '|');
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/tyencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, "|");
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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)
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, _) => {
Expand Down Expand Up @@ -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
})
Expand Down Expand Up @@ -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)));
}
}
Expand Down
Loading