Skip to content

Commit 2a77906

Browse files
committed
Use Names in the remaining HIR structures with exception of...
PathSegment, PatIdent, ExprWhile, ExprLoop, ExprBreak and ExprAgain - they need Idents for resolve
1 parent a636a83 commit 2a77906

File tree

28 files changed

+86
-86
lines changed

28 files changed

+86
-86
lines changed

src/librustc/front/map/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ impl<'ast> Map<'ast> {
483483
NodeForeignItem(i) => PathName(i.name),
484484
NodeImplItem(ii) => PathName(ii.name),
485485
NodeTraitItem(ti) => PathName(ti.name),
486-
NodeVariant(v) => PathName(v.node.name.name),
486+
NodeVariant(v) => PathName(v.node.name),
487487
NodeLifetime(lt) => PathName(lt.name),
488488
_ => panic!("no path elem for {:?}", node)
489489
}
@@ -710,7 +710,7 @@ impl<T:Named> Named for Spanned<T> { fn name(&self) -> Name { self.node.name() }
710710

711711
impl Named for Item { fn name(&self) -> Name { self.name } }
712712
impl Named for ForeignItem { fn name(&self) -> Name { self.name } }
713-
impl Named for Variant_ { fn name(&self) -> Name { self.name.name } }
713+
impl Named for Variant_ { fn name(&self) -> Name { self.name } }
714714
impl Named for TraitItem { fn name(&self) -> Name { self.name } }
715715
impl Named for ImplItem { fn name(&self) -> Name { self.name } }
716716

src/librustc/middle/check_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
526526
.map(|(field, pat)| Spanned {
527527
span: DUMMY_SP,
528528
node: hir::FieldPat {
529-
ident: ast::Ident::new(field.name),
529+
name: field.name,
530530
pat: pat,
531531
is_shorthand: false,
532532
}
@@ -910,7 +910,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
910910
let def_variant = adt.variant_of_def(def);
911911
if variant.did == def_variant.did {
912912
Some(variant.fields.iter().map(|sf| {
913-
match pattern_fields.iter().find(|f| f.node.ident.name == sf.name) {
913+
match pattern_fields.iter().find(|f| f.node.name == sf.name) {
914914
Some(ref f) => &*f.node.pat,
915915
_ => DUMMY_WILD_PAT
916916
}

src/librustc/middle/const_eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P<hir::Pat>
314314
let field_pats = fields.iter().map(|field| codemap::Spanned {
315315
span: codemap::DUMMY_SP,
316316
node: hir::FieldPat {
317-
ident: ast::Ident::new(field.name.node),
317+
name: field.name.node,
318318
pat: const_expr_to_pat(tcx, &*field.expr, span),
319319
is_shorthand: false,
320320
},

src/librustc/middle/dead.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
137137
if let hir::PatWild(hir::PatWildSingle) = pat.node.pat.node {
138138
continue;
139139
}
140-
self.live_symbols.insert(variant.field_named(pat.node.ident.name).did.node);
140+
self.live_symbols.insert(variant.field_named(pat.node.name).did.node);
141141
}
142142
}
143143

@@ -443,7 +443,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
443443
}
444444

445445
fn should_warn_about_field(&mut self, node: &hir::StructField_) -> bool {
446-
let is_named = node.ident().is_some();
446+
let is_named = node.name().is_some();
447447
let field_type = self.tcx.node_id_to_type(node.id);
448448
let is_marker_field = match field_type.ty_to_def_id() {
449449
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> {
529529
for variant in &enum_def.variants {
530530
if self.should_warn_about_variant(&variant.node) {
531531
self.warn_dead_code(variant.node.id, variant.span,
532-
variant.node.name.name, "variant");
532+
variant.node.name, "variant");
533533
}
534534
}
535535
},
@@ -549,7 +549,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
549549
fn visit_struct_field(&mut self, field: &hir::StructField) {
550550
if self.should_warn_about_field(&field.node) {
551551
self.warn_dead_code(field.node.id, field.span,
552-
field.node.ident().unwrap().name, "struct field");
552+
field.node.name().unwrap(), "struct field");
553553
}
554554

555555
visit::walk_struct_field(self, field);

src/librustc/middle/infer/error_reporting.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
11981198
lifetime,
11991199
region_names);
12001200
hir::TyParam {
1201-
ident: ty_param.ident,
1201+
name: ty_param.name,
12021202
id: ty_param.id,
12031203
bounds: bounds,
12041204
default: ty_param.default.clone(),
@@ -1541,7 +1541,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
15411541
let new_bindings = data.bindings.map(|b| {
15421542
P(hir::TypeBinding {
15431543
id: b.id,
1544-
ident: b.ident,
1544+
name: b.name,
15451545
ty: self.rebuild_arg_ty_or_output(&*b.ty,
15461546
lifetime,
15471547
anon_nums,

src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
12721272
// {f1: p1, ..., fN: pN}
12731273
for fp in field_pats {
12741274
let field_ty = try!(self.pat_ty(&*fp.node.pat)); // see (*2)
1275-
let cmt_field = self.cat_field(pat, cmt.clone(), fp.node.ident.name, field_ty);
1275+
let cmt_field = self.cat_field(pat, cmt.clone(), fp.node.name, field_ty);
12761276
try!(self.cat_pattern_(cmt_field, &*fp.node.pat, op));
12771277
}
12781278
}

src/librustc/middle/stability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ pub fn check_pat(tcx: &ty::ctxt, pat: &hir::Pat,
513513
// Foo { a, b, c }
514514
hir::PatStruct(_, ref pat_fields, _) => {
515515
for field in pat_fields {
516-
let did = v.field_named(field.node.ident.name).did;
516+
let did = v.field_named(field.node.name).did;
517517
maybe_do_stability_check(tcx, did, field.span, cb);
518518
}
519519
}

src/librustc_front/fold.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,9 @@ pub fn noop_fold_decl<T: Folder>(d: P<Decl>, fld: &mut T) -> SmallVector<P<Decl>
355355
}
356356

357357
pub fn noop_fold_ty_binding<T: Folder>(b: P<TypeBinding>, fld: &mut T) -> P<TypeBinding> {
358-
b.map(|TypeBinding { id, ident, ty, span }| TypeBinding {
358+
b.map(|TypeBinding { id, name, ty, span }| TypeBinding {
359359
id: fld.new_id(id),
360-
ident: ident,
360+
name: name,
361361
ty: fld.fold_ty(ty),
362362
span: fld.new_span(span),
363363
})
@@ -576,10 +576,10 @@ pub fn noop_fold_ty_param_bound<T>(tpb: TyParamBound, fld: &mut T)
576576
}
577577

578578
pub fn noop_fold_ty_param<T: Folder>(tp: TyParam, fld: &mut T) -> TyParam {
579-
let TyParam {id, ident, bounds, default, span} = tp;
579+
let TyParam {id, name, bounds, default, span} = tp;
580580
TyParam {
581581
id: fld.new_id(id),
582-
ident: ident,
582+
name: name,
583583
bounds: fld.fold_bounds(bounds),
584584
default: default.map(|x| fld.fold_ty(x)),
585585
span: span
@@ -1009,7 +1009,7 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> {
10091009
let fs = fields.move_map(|f| {
10101010
Spanned { span: folder.new_span(f.span),
10111011
node: hir::FieldPat {
1012-
ident: f.node.ident,
1012+
name: f.node.name,
10131013
pat: folder.fold_pat(f.node.pat),
10141014
is_shorthand: f.node.is_shorthand,
10151015
}}

src/librustc_front/hir.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ pub type TyParamBounds = OwnedSlice<TyParamBound>;
244244

245245
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
246246
pub struct TyParam {
247-
pub ident: Ident,
247+
pub name: Name,
248248
pub id: NodeId,
249249
pub bounds: TyParamBounds,
250250
pub default: Option<P<Ty>>,
@@ -378,7 +378,7 @@ impl fmt::Debug for Pat {
378378
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
379379
pub struct FieldPat {
380380
/// The identifier for the field
381-
pub ident: Ident,
381+
pub name: Name,
382382
/// The pattern the field is destructured to
383383
pub pat: P<Pat>,
384384
pub is_shorthand: bool,
@@ -791,7 +791,7 @@ pub enum ImplItem_ {
791791
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
792792
pub struct TypeBinding {
793793
pub id: NodeId,
794-
pub ident: Ident,
794+
pub name: Name,
795795
pub ty: P<Ty>,
796796
pub span: Span,
797797
}
@@ -981,11 +981,11 @@ pub enum ExplicitSelf_ {
981981
/// No self
982982
SelfStatic,
983983
/// `self`
984-
SelfValue(Ident),
984+
SelfValue(Name),
985985
/// `&'lt self`, `&'lt mut self`
986-
SelfRegion(Option<Lifetime>, Mutability, Ident),
986+
SelfRegion(Option<Lifetime>, Mutability, Name),
987987
/// `self: TYPE`
988-
SelfExplicit(P<Ty>, Ident),
988+
SelfExplicit(P<Ty>, Name),
989989
}
990990

991991
pub type ExplicitSelf = Spanned<ExplicitSelf_>;
@@ -1026,7 +1026,7 @@ pub struct EnumDef {
10261026

10271027
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
10281028
pub struct Variant_ {
1029-
pub name: Ident,
1029+
pub name: Name,
10301030
pub attrs: Vec<Attribute>,
10311031
pub kind: VariantKind,
10321032
pub id: NodeId,
@@ -1133,9 +1133,9 @@ pub struct StructField_ {
11331133
}
11341134

11351135
impl StructField_ {
1136-
pub fn ident(&self) -> Option<Ident> {
1136+
pub fn name(&self) -> Option<Name> {
11371137
match self.kind {
1138-
NamedField(ref ident, _) => Some(ident.clone()),
1138+
NamedField(name, _) => Some(name),
11391139
UnnamedField(_) => None
11401140
}
11411141
}
@@ -1145,7 +1145,7 @@ pub type StructField = Spanned<StructField_>;
11451145

11461146
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
11471147
pub enum StructFieldKind {
1148-
NamedField(Ident, Visibility),
1148+
NamedField(Name, Visibility),
11491149
/// Element of a tuple-like struct
11501150
UnnamedField(Visibility),
11511151
}

src/librustc_front/lowering.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub fn lower_decl(d: &Decl) -> P<hir::Decl> {
7676
}
7777

7878
pub fn lower_ty_binding(b: &TypeBinding) -> P<hir::TypeBinding> {
79-
P(hir::TypeBinding { id: b.id, ident: b.ident, ty: lower_ty(&b.ty), span: b.span })
79+
P(hir::TypeBinding { id: b.id, name: b.ident.name, ty: lower_ty(&b.ty), span: b.span })
8080
}
8181

8282
pub fn lower_ty(t: &Ty) -> P<hir::Ty> {
@@ -138,7 +138,7 @@ pub fn lower_variant(v: &Variant) -> P<hir::Variant> {
138138
P(Spanned {
139139
node: hir::Variant_ {
140140
id: v.node.id,
141-
name: v.node.name,
141+
name: v.node.name.name,
142142
attrs: v.node.attrs.clone(),
143143
kind: match v.node.kind {
144144
TupleVariantKind(ref variant_args) => {
@@ -209,12 +209,12 @@ pub fn lower_local(l: &Local) -> P<hir::Local> {
209209
pub fn lower_explicit_self_underscore(es: &ExplicitSelf_) -> hir::ExplicitSelf_ {
210210
match *es {
211211
SelfStatic => hir::SelfStatic,
212-
SelfValue(v) => hir::SelfValue(v),
212+
SelfValue(v) => hir::SelfValue(v.name),
213213
SelfRegion(ref lifetime, m, ident) => {
214-
hir::SelfRegion(lower_opt_lifetime(lifetime), lower_mutability(m), ident)
214+
hir::SelfRegion(lower_opt_lifetime(lifetime), lower_mutability(m), ident.name)
215215
}
216216
SelfExplicit(ref typ, ident) => {
217-
hir::SelfExplicit(lower_ty(typ), ident)
217+
hir::SelfExplicit(lower_ty(typ), ident.name)
218218
}
219219
}
220220
}
@@ -258,7 +258,7 @@ pub fn lower_ty_param_bound(tpb: &TyParamBound) -> hir::TyParamBound {
258258
pub fn lower_ty_param(tp: &TyParam) -> hir::TyParam {
259259
hir::TyParam {
260260
id: tp.id,
261-
ident: tp.ident,
261+
name: tp.ident.name,
262262
bounds: lower_bounds(&tp.bounds),
263263
default: tp.default.as_ref().map(|x| lower_ty(x)),
264264
span: tp.span,
@@ -665,7 +665,7 @@ pub fn lower_pat(p: &Pat) -> P<hir::Pat> {
665665
let fs = fields.iter().map(|f| {
666666
Spanned { span: f.span,
667667
node: hir::FieldPat {
668-
ident: f.node.ident,
668+
name: f.node.ident.name,
669669
pat: lower_pat(&f.node.pat),
670670
is_shorthand: f.node.is_shorthand,
671671
}}
@@ -901,7 +901,7 @@ pub fn lower_binding_mode(b: &BindingMode) -> hir::BindingMode {
901901

902902
pub fn lower_struct_field_kind(s: &StructFieldKind) -> hir::StructFieldKind {
903903
match *s {
904-
NamedField(ident, vis) => hir::NamedField(ident, lower_visibility(vis)),
904+
NamedField(ident, vis) => hir::NamedField(ident.name, lower_visibility(vis)),
905905
UnnamedField(vis) => hir::UnnamedField(lower_visibility(vis)),
906906
}
907907
}

0 commit comments

Comments
 (0)