Use Names in the remaining HIR structures with exception of...

PathSegment, PatIdent, ExprWhile, ExprLoop, ExprBreak and ExprAgain - they need Idents for resolve
This commit is contained in:
Vadim Petrochenkov 2015-09-20 16:47:24 +03:00
parent a636a83caa
commit 2a779062d8
28 changed files with 86 additions and 86 deletions

View File

@ -483,7 +483,7 @@ impl<'ast> Map<'ast> {
NodeForeignItem(i) => PathName(i.name),
NodeImplItem(ii) => PathName(ii.name),
NodeTraitItem(ti) => PathName(ti.name),
NodeVariant(v) => PathName(v.node.name.name),
NodeVariant(v) => PathName(v.node.name),
NodeLifetime(lt) => PathName(lt.name),
_ => panic!("no path elem for {:?}", node)
}
@ -710,7 +710,7 @@ impl<T:Named> Named for Spanned<T> { fn name(&self) -> Name { self.node.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 Variant_ { fn name(&self) -> Name { self.name } }
impl Named for TraitItem { fn name(&self) -> Name { self.name } }
impl Named for ImplItem { fn name(&self) -> Name { self.name } }

View File

@ -526,7 +526,7 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
.map(|(field, pat)| Spanned {
span: DUMMY_SP,
node: hir::FieldPat {
ident: ast::Ident::new(field.name),
name: field.name,
pat: pat,
is_shorthand: false,
}
@ -910,7 +910,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
let def_variant = adt.variant_of_def(def);
if variant.did == def_variant.did {
Some(variant.fields.iter().map(|sf| {
match pattern_fields.iter().find(|f| f.node.ident.name == sf.name) {
match pattern_fields.iter().find(|f| f.node.name == sf.name) {
Some(ref f) => &*f.node.pat,
_ => DUMMY_WILD_PAT
}

View File

@ -314,7 +314,7 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P<hir::Pat>
let field_pats = fields.iter().map(|field| codemap::Spanned {
span: codemap::DUMMY_SP,
node: hir::FieldPat {
ident: ast::Ident::new(field.name.node),
name: field.name.node,
pat: const_expr_to_pat(tcx, &*field.expr, span),
is_shorthand: false,
},

View File

@ -137,7 +137,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
if let hir::PatWild(hir::PatWildSingle) = pat.node.pat.node {
continue;
}
self.live_symbols.insert(variant.field_named(pat.node.ident.name).did.node);
self.live_symbols.insert(variant.field_named(pat.node.name).did.node);
}
}
@ -443,7 +443,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
}
fn should_warn_about_field(&mut self, node: &hir::StructField_) -> bool {
let is_named = node.ident().is_some();
let is_named = node.name().is_some();
let field_type = self.tcx.node_id_to_type(node.id);
let is_marker_field = match field_type.ty_to_def_id() {
Some(def_id) => self.tcx.lang_items.items().any(|(_, item)| *item == Some(def_id)),
@ -529,7 +529,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
for variant in &enum_def.variants {
if self.should_warn_about_variant(&variant.node) {
self.warn_dead_code(variant.node.id, variant.span,
variant.node.name.name, "variant");
variant.node.name, "variant");
}
}
},
@ -549,7 +549,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
fn visit_struct_field(&mut self, field: &hir::StructField) {
if self.should_warn_about_field(&field.node) {
self.warn_dead_code(field.node.id, field.span,
field.node.ident().unwrap().name, "struct field");
field.node.name().unwrap(), "struct field");
}
visit::walk_struct_field(self, field);

View File

@ -1198,7 +1198,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
lifetime,
region_names);
hir::TyParam {
ident: ty_param.ident,
name: ty_param.name,
id: ty_param.id,
bounds: bounds,
default: ty_param.default.clone(),
@ -1541,7 +1541,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
let new_bindings = data.bindings.map(|b| {
P(hir::TypeBinding {
id: b.id,
ident: b.ident,
name: b.name,
ty: self.rebuild_arg_ty_or_output(&*b.ty,
lifetime,
anon_nums,

View File

@ -1272,7 +1272,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
// {f1: p1, ..., fN: pN}
for fp in field_pats {
let field_ty = try!(self.pat_ty(&*fp.node.pat)); // see (*2)
let cmt_field = self.cat_field(pat, cmt.clone(), fp.node.ident.name, field_ty);
let cmt_field = self.cat_field(pat, cmt.clone(), fp.node.name, field_ty);
try!(self.cat_pattern_(cmt_field, &*fp.node.pat, op));
}
}

View File

@ -513,7 +513,7 @@ pub fn check_pat(tcx: &ty::ctxt, pat: &hir::Pat,
// Foo { a, b, c }
hir::PatStruct(_, ref pat_fields, _) => {
for field in pat_fields {
let did = v.field_named(field.node.ident.name).did;
let did = v.field_named(field.node.name).did;
maybe_do_stability_check(tcx, did, field.span, cb);
}
}

View File

@ -355,9 +355,9 @@ pub fn noop_fold_decl<T: Folder>(d: P<Decl>, fld: &mut T) -> SmallVector<P<Decl>
}
pub fn noop_fold_ty_binding<T: Folder>(b: P<TypeBinding>, fld: &mut T) -> P<TypeBinding> {
b.map(|TypeBinding { id, ident, ty, span }| TypeBinding {
b.map(|TypeBinding { id, name, ty, span }| TypeBinding {
id: fld.new_id(id),
ident: ident,
name: name,
ty: fld.fold_ty(ty),
span: fld.new_span(span),
})
@ -576,10 +576,10 @@ pub fn noop_fold_ty_param_bound<T>(tpb: TyParamBound, fld: &mut T)
}
pub fn noop_fold_ty_param<T: Folder>(tp: TyParam, fld: &mut T) -> TyParam {
let TyParam {id, ident, bounds, default, span} = tp;
let TyParam {id, name, bounds, default, span} = tp;
TyParam {
id: fld.new_id(id),
ident: ident,
name: name,
bounds: fld.fold_bounds(bounds),
default: default.map(|x| fld.fold_ty(x)),
span: span
@ -1009,7 +1009,7 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> {
let fs = fields.move_map(|f| {
Spanned { span: folder.new_span(f.span),
node: hir::FieldPat {
ident: f.node.ident,
name: f.node.name,
pat: folder.fold_pat(f.node.pat),
is_shorthand: f.node.is_shorthand,
}}

View File

@ -244,7 +244,7 @@ pub type TyParamBounds = OwnedSlice<TyParamBound>;
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct TyParam {
pub ident: Ident,
pub name: Name,
pub id: NodeId,
pub bounds: TyParamBounds,
pub default: Option<P<Ty>>,
@ -378,7 +378,7 @@ impl fmt::Debug for Pat {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct FieldPat {
/// The identifier for the field
pub ident: Ident,
pub name: Name,
/// The pattern the field is destructured to
pub pat: P<Pat>,
pub is_shorthand: bool,
@ -791,7 +791,7 @@ pub enum ImplItem_ {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct TypeBinding {
pub id: NodeId,
pub ident: Ident,
pub name: Name,
pub ty: P<Ty>,
pub span: Span,
}
@ -981,11 +981,11 @@ pub enum ExplicitSelf_ {
/// No self
SelfStatic,
/// `self`
SelfValue(Ident),
SelfValue(Name),
/// `&'lt self`, `&'lt mut self`
SelfRegion(Option<Lifetime>, Mutability, Ident),
SelfRegion(Option<Lifetime>, Mutability, Name),
/// `self: TYPE`
SelfExplicit(P<Ty>, Ident),
SelfExplicit(P<Ty>, Name),
}
pub type ExplicitSelf = Spanned<ExplicitSelf_>;
@ -1026,7 +1026,7 @@ pub struct EnumDef {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct Variant_ {
pub name: Ident,
pub name: Name,
pub attrs: Vec<Attribute>,
pub kind: VariantKind,
pub id: NodeId,
@ -1133,9 +1133,9 @@ pub struct StructField_ {
}
impl StructField_ {
pub fn ident(&self) -> Option<Ident> {
pub fn name(&self) -> Option<Name> {
match self.kind {
NamedField(ref ident, _) => Some(ident.clone()),
NamedField(name, _) => Some(name),
UnnamedField(_) => None
}
}
@ -1145,7 +1145,7 @@ pub type StructField = Spanned<StructField_>;
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum StructFieldKind {
NamedField(Ident, Visibility),
NamedField(Name, Visibility),
/// Element of a tuple-like struct
UnnamedField(Visibility),
}

View File

@ -76,7 +76,7 @@ pub fn lower_decl(d: &Decl) -> P<hir::Decl> {
}
pub fn lower_ty_binding(b: &TypeBinding) -> P<hir::TypeBinding> {
P(hir::TypeBinding { id: b.id, ident: b.ident, ty: lower_ty(&b.ty), span: b.span })
P(hir::TypeBinding { id: b.id, name: b.ident.name, ty: lower_ty(&b.ty), span: b.span })
}
pub fn lower_ty(t: &Ty) -> P<hir::Ty> {
@ -138,7 +138,7 @@ pub fn lower_variant(v: &Variant) -> P<hir::Variant> {
P(Spanned {
node: hir::Variant_ {
id: v.node.id,
name: v.node.name,
name: v.node.name.name,
attrs: v.node.attrs.clone(),
kind: match v.node.kind {
TupleVariantKind(ref variant_args) => {
@ -209,12 +209,12 @@ pub fn lower_local(l: &Local) -> P<hir::Local> {
pub fn lower_explicit_self_underscore(es: &ExplicitSelf_) -> hir::ExplicitSelf_ {
match *es {
SelfStatic => hir::SelfStatic,
SelfValue(v) => hir::SelfValue(v),
SelfValue(v) => hir::SelfValue(v.name),
SelfRegion(ref lifetime, m, ident) => {
hir::SelfRegion(lower_opt_lifetime(lifetime), lower_mutability(m), ident)
hir::SelfRegion(lower_opt_lifetime(lifetime), lower_mutability(m), ident.name)
}
SelfExplicit(ref typ, ident) => {
hir::SelfExplicit(lower_ty(typ), ident)
hir::SelfExplicit(lower_ty(typ), ident.name)
}
}
}
@ -258,7 +258,7 @@ pub fn lower_ty_param_bound(tpb: &TyParamBound) -> hir::TyParamBound {
pub fn lower_ty_param(tp: &TyParam) -> hir::TyParam {
hir::TyParam {
id: tp.id,
ident: tp.ident,
name: tp.ident.name,
bounds: lower_bounds(&tp.bounds),
default: tp.default.as_ref().map(|x| lower_ty(x)),
span: tp.span,
@ -665,7 +665,7 @@ pub fn lower_pat(p: &Pat) -> P<hir::Pat> {
let fs = fields.iter().map(|f| {
Spanned { span: f.span,
node: hir::FieldPat {
ident: f.node.ident,
name: f.node.ident.name,
pat: lower_pat(&f.node.pat),
is_shorthand: f.node.is_shorthand,
}}
@ -901,7 +901,7 @@ pub fn lower_binding_mode(b: &BindingMode) -> hir::BindingMode {
pub fn lower_struct_field_kind(s: &StructFieldKind) -> hir::StructFieldKind {
match *s {
NamedField(ident, vis) => hir::NamedField(ident, lower_visibility(vis)),
NamedField(ident, vis) => hir::NamedField(ident.name, lower_visibility(vis)),
UnnamedField(vis) => hir::UnnamedField(lower_visibility(vis)),
}
}

View File

@ -926,12 +926,12 @@ impl<'a> State<'a> {
for field in &struct_def.fields {
match field.node.kind {
hir::UnnamedField(..) => panic!("unexpected unnamed field"),
hir::NamedField(ident, visibility) => {
hir::NamedField(name, visibility) => {
try!(self.hardbreak_if_not_bol());
try!(self.maybe_print_comment(field.span.lo));
try!(self.print_outer_attributes(&field.node.attrs));
try!(self.print_visibility(visibility));
try!(self.print_ident(ident));
try!(self.print_name(name));
try!(self.word_nbsp(":"));
try!(self.print_type(&*field.node.ty));
try!(word(&mut self.s, ","));
@ -946,7 +946,7 @@ impl<'a> State<'a> {
pub fn print_variant(&mut self, v: &hir::Variant) -> io::Result<()> {
match v.node.kind {
hir::TupleVariantKind(ref args) => {
try!(self.print_ident(v.node.name));
try!(self.print_name(v.node.name));
if !args.is_empty() {
try!(self.popen());
try!(self.commasep(Consistent,
@ -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.name, v.span));
try!(self.print_struct(&**struct_def, &generics, v.node.name, v.span));
}
}
match v.node.disr_expr {
@ -1699,7 +1699,7 @@ impl<'a> State<'a> {
if comma {
try!(self.word_space(","))
}
try!(self.print_ident(binding.ident));
try!(self.print_name(binding.name));
try!(space(&mut self.s));
try!(self.word_space("="));
try!(self.print_type(&*binding.ty));
@ -1785,7 +1785,7 @@ impl<'a> State<'a> {
|s, f| {
try!(s.cbox(indent_unit));
if !f.node.is_shorthand {
try!(s.print_ident(f.node.ident));
try!(s.print_name(f.node.name));
try!(s.word_nbsp(":"));
}
try!(s.print_pat(&*f.node.pat));
@ -2111,7 +2111,7 @@ impl<'a> State<'a> {
}
pub fn print_ty_param(&mut self, param: &hir::TyParam) -> io::Result<()> {
try!(self.print_ident(param.ident));
try!(self.print_name(param.name));
try!(self.print_bounds(":", &param.bounds));
match param.default {
Some(ref default) => {

View File

@ -299,7 +299,7 @@ pub fn walk_enum_def<'v, V: Visitor<'v>>(visitor: &mut V,
pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V,
variant: &'v Variant,
generics: &'v Generics) {
visitor.visit_name(variant.span, variant.node.name.name);
visitor.visit_name(variant.span, variant.node.name);
match variant.node.kind {
TupleVariantKind(ref variant_arguments) => {
@ -309,7 +309,7 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V,
}
StructVariantKind(ref struct_definition) => {
visitor.visit_struct_def(&**struct_definition,
variant.node.name.name,
variant.node.name,
generics,
variant.node.id)
}
@ -441,7 +441,7 @@ pub fn walk_path_parameters<'v, V: Visitor<'v>>(visitor: &mut V,
pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V,
type_binding: &'v TypeBinding) {
visitor.visit_name(type_binding.span, type_binding.ident.name);
visitor.visit_name(type_binding.span, type_binding.name);
visitor.visit_ty(&*type_binding.ty);
}
@ -539,7 +539,7 @@ pub fn walk_ty_param_bound<'v, V: Visitor<'v>>(visitor: &mut V,
pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics) {
for param in generics.ty_params.iter() {
visitor.visit_name(param.span, param.ident.name);
visitor.visit_name(param.span, param.name);
walk_ty_param_bounds_helper(visitor, &param.bounds);
walk_ty_opt(visitor, &param.default);
}
@ -668,7 +668,7 @@ pub fn walk_struct_def<'v, V: Visitor<'v>>(visitor: &mut V,
pub fn walk_struct_field<'v, V: Visitor<'v>>(visitor: &mut V,
struct_field: &'v StructField) {
if let NamedField(name, _) = struct_field.node.kind {
visitor.visit_name(struct_field.span, name.name);
visitor.visit_name(struct_field.span, name);
}
visitor.visit_ty(&*struct_field.node.ty);

View File

@ -909,7 +909,7 @@ impl LateLintPass for NonShorthandFieldPatterns {
});
for fieldpat in field_pats {
if let hir::PatIdent(_, ident, None) = fieldpat.node.pat.node {
if ident.node.name == fieldpat.node.ident.name {
if ident.node.name == fieldpat.node.name {
// FIXME: should this comparison really be done on the name?
// doing it on the ident will fail during compilation of libcore
cx.span_lint(NON_SHORTHAND_FIELD_PATTERNS, fieldpat.span,

View File

@ -268,7 +268,7 @@ impl<'a,'tcx:'a> Mirror<Cx<'a,'tcx>> for PatNode<'tcx> {
let subpatterns =
fields.iter()
.map(|field| FieldPatternRef {
field: Field::Named(field.node.ident.name),
field: Field::Named(field.node.name),
pattern: self.pat_ref(&field.node.pat),
})
.collect();

View File

@ -941,7 +941,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
let variant = adt.variant_of_def(def);
for field in fields {
self.check_field(pattern.span, adt, variant,
NamedField(field.node.ident.name));
NamedField(field.node.name));
}
}

View File

@ -508,7 +508,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
// Record the def ID and fields of this struct.
let named_fields = struct_def.fields.iter().filter_map(|f| {
match f.node.kind {
NamedField(ident, _) => Some(ident.name),
NamedField(name, _) => Some(name),
UnnamedField(_) => None
}
}).collect();
@ -578,7 +578,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
variant: &Variant,
item_id: DefId,
parent: &Rc<Module>) {
let name = variant.node.name.name;
let name = variant.node.name;
let is_exported = match variant.node.kind {
TupleVariantKind(_) => false,
StructVariantKind(_) => {

View File

@ -509,7 +509,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
}
hir::StructVariantKind(ref struct_definition) => {
self.visit_struct_def(&**struct_definition,
variant.node.name.name,
variant.node.name,
generics,
variant.node.id);
}
@ -2264,7 +2264,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
let mut function_type_rib = Rib::new(rib_kind);
let mut seen_bindings = HashSet::new();
for (index, type_parameter) in generics.ty_params.iter().enumerate() {
let name = type_parameter.ident.name;
let name = type_parameter.name;
debug!("with_type_parameter_rib: {}", type_parameter.id);
if seen_bindings.contains(&name) {
@ -2390,7 +2390,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
fn resolve_generics(&mut self, generics: &Generics) {
for type_parameter in generics.ty_params.iter() {
self.check_if_primitive_type_name(type_parameter.ident.name, type_parameter.span);
self.check_if_primitive_type_name(type_parameter.name, type_parameter.span);
}
for predicate in &generics.where_clause.predicates {
match predicate {

View File

@ -1872,7 +1872,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let pat_repr = adt::represent_type(bcx.ccx(), pat_ty);
let pat_v = VariantInfo::of_node(tcx, pat_ty, pat.id);
for f in fields {
let name = f.node.ident.name;
let name = f.node.name;
let fldptr = adt::trans_field_ptr(
bcx,
&*pat_repr,

View File

@ -520,7 +520,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// Handle other generic parameters
let actual_types = param_substs.types.get_slice(subst::FnSpace);
for (index, &hir::TyParam{ ident, .. }) in generics.ty_params.iter().enumerate() {
for (index, &hir::TyParam{ name, .. }) in generics.ty_params.iter().enumerate() {
let actual_type = actual_types[index];
// Add actual type name to <...> clause of function name
let actual_type_name = compute_debuginfo_type_name(cx,
@ -535,7 +535,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// Again, only create type information if full debuginfo is enabled
if cx.sess().opts.debuginfo == FullDebugInfo {
let actual_type_metadata = type_metadata(cx, actual_type, codemap::DUMMY_SP);
let name = CString::new(ident.name.as_str().as_bytes()).unwrap();
let name = CString::new(name.as_str().as_bytes()).unwrap();
let param_metadata = unsafe {
llvm::LLVMDIBuilderCreateTemplateTypeParameter(
DIB(cx),

View File

@ -194,7 +194,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
hir_map::NodeVariant(v) => {
let variant = inlined_variant_def(ccx, fn_id.node);
assert_eq!(v.node.name.name, variant.name);
assert_eq!(v.node.name, variant.name);
let d = mk_lldecl(abi::Rust);
attributes::inline(d, attributes::InlineAttr::Hint);
trans_enum_variant(ccx, fn_id.node, variant.disr_val, psubsts, d);

View File

@ -545,7 +545,7 @@ fn convert_angle_bracketed_parameters<'tcx>(this: &AstConv<'tcx>,
let assoc_bindings: Vec<_> =
data.bindings.iter()
.map(|b| ConvertedBinding { item_name: b.ident.name,
.map(|b| ConvertedBinding { item_name: b.name,
ty: ast_ty_to_ty(this, rscope, &*b.ty),
span: b.span })
.collect();

View File

@ -706,25 +706,25 @@ pub fn check_struct_pat_fields<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
// Typecheck each field.
for &Spanned { node: ref field, span } in fields {
let field_ty = match used_fields.entry(field.ident.name) {
let field_ty = match used_fields.entry(field.name) {
Occupied(occupied) => {
span_err!(tcx.sess, span, E0025,
"field `{}` bound multiple times in the pattern",
field.ident);
field.name);
span_note!(tcx.sess, *occupied.get(),
"field `{}` previously bound here",
field.ident);
field.name);
tcx.types.err
}
Vacant(vacant) => {
vacant.insert(span);
field_map.get(&field.ident.name)
field_map.get(&field.name)
.map(|f| pcx.fcx.field_ty(span, f, substs))
.unwrap_or_else(|| {
span_err!(tcx.sess, span, E0026,
"struct `{}` does not have a field named `{}`",
tcx.item_path_str(variant.did),
field.ident);
field.name);
tcx.types.err
})
}

View File

@ -838,7 +838,7 @@ fn check_trait_on_unimplemented<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
Position::ArgumentNamed(s) if s == "Self" => (),
// So is `{A}` if A is a type parameter
Position::ArgumentNamed(s) => match types.iter().find(|t| {
t.ident.name == s
t.name == s
}) {
Some(_) => (),
None => {
@ -4938,7 +4938,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
if !*b {
span_err!(ccx.tcx.sess, span, E0091,
"type parameter `{}` is unused",
tps[i].ident);
tps[i].name);
}
}
}

View File

@ -324,7 +324,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
-> ty::ParamTy
{
let name = match space {
TypeSpace => ast_generics.ty_params[index].ident.name,
TypeSpace => ast_generics.ty_params[index].name,
SelfSpace => special_idents::type_self.name,
FnSpace => self.tcx().sess.bug("Fn space occupied?"),
};

View File

@ -431,7 +431,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
-> ty::ParamTy
{
let name = match space {
TypeSpace => ast_generics.ty_params[index].ident.name,
TypeSpace => ast_generics.ty_params[index].name,
SelfSpace => special_idents::type_self.name,
FnSpace => self.tcx().sess.bug("Fn space occupied?"),
};

View File

@ -1099,18 +1099,18 @@ fn convert_struct_variant<'tcx>(tcx: &ty::ctxt<'tcx>,
let fields = def.fields.iter().map(|f| {
let fid = DefId::local(f.node.id);
match f.node.kind {
hir::NamedField(ident, vis) => {
let dup_span = seen_fields.get(&ident.name).cloned();
hir::NamedField(name, vis) => {
let dup_span = seen_fields.get(&name).cloned();
if let Some(prev_span) = dup_span {
span_err!(tcx.sess, f.span, E0124,
"field `{}` is already declared",
ident.name);
name);
span_note!(tcx.sess, prev_span, "previously declared here");
} else {
seen_fields.insert(ident.name, f.span);
seen_fields.insert(name, f.span);
}
ty::FieldDefData::new(fid, ident.name, vis)
ty::FieldDefData::new(fid, name, vis)
},
hir::UnnamedField(vis) => {
ty::FieldDefData::new(fid, special_idents::unnamed_field.name, vis)
@ -1195,7 +1195,7 @@ fn convert_enum_def<'tcx>(tcx: &ty::ctxt<'tcx>,
if let Some(prev_disr_val) = prev_disr_val {
let result = repr_type.disr_incr(prev_disr_val);
if let None = result {
report_discrim_overflow(tcx, v.span, &v.node.name.name.as_str(),
report_discrim_overflow(tcx, v.span, &v.node.name.as_str(),
repr_type, prev_disr_val);
}
result
@ -1209,7 +1209,7 @@ fn convert_enum_def<'tcx>(tcx: &ty::ctxt<'tcx>,
-> ty::VariantDefData<'tcx, 'tcx>
{
let did = DefId::local(v.node.id);
let name = v.node.name.name;
let name = v.node.name;
match v.node.kind {
hir::TupleVariantKind(ref va) => {
ty::VariantDefData {
@ -1417,7 +1417,7 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
.iter()
.enumerate()
.map(|(i, def)| tcx.mk_param(TypeSpace,
i as u32, def.ident.name))
i as u32, def.name))
.collect();
// ...and also create the `Self` parameter.
@ -1862,7 +1862,7 @@ fn ty_generic_predicates<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
// type parameter (e.g., `<T:Foo>`).
for (index, param) in ast_generics.ty_params.iter().enumerate() {
let index = index as u32;
let param_ty = ty::ParamTy::new(space, index, param.ident.name).to_ty(ccx.tcx);
let param_ty = ty::ParamTy::new(space, index, param.name).to_ty(ccx.tcx);
let bounds = compute_bounds(&ccx.icx(&(base_predicates, ast_generics)),
param_ty,
&param.bounds,
@ -2033,7 +2033,7 @@ fn get_or_create_type_parameter_def<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
let def = ty::TypeParameterDef {
space: space,
index: index,
name: param.ident.name,
name: param.name,
def_id: DefId::local(param.id),
default_def_id: DefId::local(parent),
default: default,
@ -2415,7 +2415,7 @@ fn enforce_impl_params_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>,
for (index, ty_param) in ast_generics.ty_params.iter().enumerate() {
let param_ty = ty::ParamTy { space: TypeSpace,
idx: index as u32,
name: ty_param.ident.name };
name: ty_param.name };
if !input_parameters.contains(&ctp::Parameter::Type(param_ty)) {
report_unused_parameter(tcx, ty_param.span, "type", &param_ty.to_string());
}

View File

@ -494,7 +494,7 @@ pub struct TyParam {
impl Clean<TyParam> for hir::TyParam {
fn clean(&self, cx: &DocContext) -> TyParam {
TyParam {
name: self.ident.clean(cx),
name: self.name.clean(cx),
did: DefId { krate: LOCAL_CRATE, node: self.id },
bounds: self.bounds.clean(cx),
default: self.default.clean(cx),
@ -2547,7 +2547,7 @@ fn name_from_pat(p: &hir::Pat) -> String {
PatStruct(ref name, ref fields, etc) => {
format!("{} {{ {}{} }}", path_to_string(name),
fields.iter().map(|&Spanned { node: ref fp, .. }|
format!("{}: {}", fp.ident, name_from_pat(&*fp.pat)))
format!("{}: {}", fp.name, name_from_pat(&*fp.pat)))
.collect::<Vec<String>>().join(", "),
if etc { ", ..." } else { "" }
)
@ -2840,7 +2840,7 @@ pub struct TypeBinding {
impl Clean<TypeBinding> for hir::TypeBinding {
fn clean(&self, cx: &DocContext) -> TypeBinding {
TypeBinding {
name: self.ident.clean(cx),
name: self.name.clean(cx),
ty: self.ty.clean(cx)
}
}

View File

@ -17,7 +17,7 @@ use syntax;
use syntax::codemap::Span;
use syntax::abi;
use syntax::ast;
use syntax::ast::{Ident, Name, NodeId};
use syntax::ast::{Name, NodeId};
use syntax::attr;
use syntax::ptr::P;
use rustc_front::hir;
@ -117,7 +117,7 @@ pub struct Enum {
}
pub struct Variant {
pub name: Ident,
pub name: Name,
pub attrs: Vec<ast::Attribute>,
pub kind: hir::VariantKind,
pub id: ast::NodeId,