Skip to content

Commit 30af54d

Browse files
committed
Dict -> Struct, StructDef -> VariantData, def -> data
1 parent f4e3851 commit 30af54d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+181
-181
lines changed

src/librustc/front/map/collector.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
134134
ItemEnum(ref enum_definition, _) => {
135135
for v in &enum_definition.variants {
136136
let variant_def_index =
137-
self.insert_def(v.node.def.id,
137+
self.insert_def(v.node.data.id,
138138
NodeVariant(&**v),
139139
DefPathData::EnumVariant(v.node.name));
140140

141-
for field in &v.node.def.fields {
141+
for field in &v.node.data.fields {
142142
self.create_def_with_parent(
143143
Some(variant_def_index),
144144
field.node.id,
@@ -150,7 +150,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
150150
}
151151
ItemStruct(ref struct_def, _) => {
152152
// If this is a tuple-like struct, register the constructor.
153-
if struct_def.kind != VariantKind::Dict {
153+
if struct_def.kind != VariantKind::Struct {
154154
self.insert_def(struct_def.id,
155155
NodeStructCtor(&**struct_def),
156156
DefPathData::StructCtor);

src/librustc/front/map/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub enum Node<'ast> {
124124
NodeBlock(&'ast Block),
125125

126126
/// NodeStructCtor represents a tuple struct.
127-
NodeStructCtor(&'ast StructDef),
127+
NodeStructCtor(&'ast VariantData),
128128

129129
NodeLifetime(&'ast Lifetime),
130130
NodeTyParam(&'ast TyParam)
@@ -149,7 +149,7 @@ pub enum MapEntry<'ast> {
149149
EntryLocal(NodeId, &'ast Pat),
150150
EntryPat(NodeId, &'ast Pat),
151151
EntryBlock(NodeId, &'ast Block),
152-
EntryStructCtor(NodeId, &'ast StructDef),
152+
EntryStructCtor(NodeId, &'ast VariantData),
153153
EntryLifetime(NodeId, &'ast Lifetime),
154154
EntryTyParam(NodeId, &'ast TyParam),
155155

@@ -471,7 +471,7 @@ impl<'ast> Map<'ast> {
471471
}
472472
}
473473

474-
pub fn expect_struct(&self, id: NodeId) -> &'ast StructDef {
474+
pub fn expect_struct(&self, id: NodeId) -> &'ast VariantData {
475475
match self.find(id) {
476476
Some(NodeItem(i)) => {
477477
match i.node {
@@ -480,8 +480,8 @@ impl<'ast> Map<'ast> {
480480
}
481481
}
482482
Some(NodeVariant(variant)) => {
483-
match variant.node.def.kind {
484-
VariantKind::Dict => &variant.node.def,
483+
match variant.node.data.kind {
484+
VariantKind::Struct => &variant.node.data,
485485
_ => panic!("struct ID bound to enum variant that isn't struct-like"),
486486
}
487487
}

src/librustc/lint/context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,8 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
661661
hir_visit::walk_fn(self, fk, decl, body, span);
662662
}
663663

664-
fn visit_struct_def(&mut self,
665-
s: &hir::StructDef,
664+
fn visit_variant_data(&mut self,
665+
s: &hir::VariantData,
666666
name: ast::Name,
667667
g: &hir::Generics,
668668
item_id: ast::NodeId,
@@ -811,8 +811,8 @@ impl<'a, 'v> ast_visit::Visitor<'v> for EarlyContext<'a> {
811811
ast_visit::walk_fn(self, fk, decl, body, span);
812812
}
813813

814-
fn visit_struct_def(&mut self,
815-
s: &ast::StructDef,
814+
fn visit_variant_data(&mut self,
815+
s: &ast::VariantData,
816816
ident: ast::Ident,
817817
g: &ast::Generics,
818818
item_id: ast::NodeId,

src/librustc/lint/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ pub trait LateLintPass: LintPass {
150150
fn check_trait_item(&mut self, _: &LateContext, _: &hir::TraitItem) { }
151151
fn check_impl_item(&mut self, _: &LateContext, _: &hir::ImplItem) { }
152152
fn check_struct_def(&mut self, _: &LateContext,
153-
_: &hir::StructDef, _: ast::Name, _: &hir::Generics, _: ast::NodeId) { }
153+
_: &hir::VariantData, _: ast::Name, _: &hir::Generics, _: ast::NodeId) { }
154154
fn check_struct_def_post(&mut self, _: &LateContext,
155-
_: &hir::StructDef, _: ast::Name, _: &hir::Generics, _: ast::NodeId) { }
155+
_: &hir::VariantData, _: ast::Name, _: &hir::Generics, _: ast::NodeId) { }
156156
fn check_struct_field(&mut self, _: &LateContext, _: &hir::StructField) { }
157157
fn check_variant(&mut self, _: &LateContext, _: &hir::Variant, _: &hir::Generics) { }
158158
fn check_variant_post(&mut self, _: &LateContext, _: &hir::Variant, _: &hir::Generics) { }
@@ -192,9 +192,9 @@ pub trait EarlyLintPass: LintPass {
192192
fn check_trait_item(&mut self, _: &EarlyContext, _: &ast::TraitItem) { }
193193
fn check_impl_item(&mut self, _: &EarlyContext, _: &ast::ImplItem) { }
194194
fn check_struct_def(&mut self, _: &EarlyContext,
195-
_: &ast::StructDef, _: ast::Ident, _: &ast::Generics, _: ast::NodeId) { }
195+
_: &ast::VariantData, _: ast::Ident, _: &ast::Generics, _: ast::NodeId) { }
196196
fn check_struct_def_post(&mut self, _: &EarlyContext,
197-
_: &ast::StructDef, _: ast::Ident, _: &ast::Generics, _: ast::NodeId) { }
197+
_: &ast::VariantData, _: ast::Ident, _: &ast::Generics, _: ast::NodeId) { }
198198
fn check_struct_field(&mut self, _: &EarlyContext, _: &ast::StructField) { }
199199
fn check_variant(&mut self, _: &EarlyContext, _: &ast::Variant, _: &ast::Generics) { }
200200
fn check_variant_post(&mut self, _: &EarlyContext, _: &ast::Variant, _: &ast::Generics) { }

src/librustc/metadata/encoder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ fn encode_enum_variant_info<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
315315
let vid = variant.did;
316316
let variant_node_id = ecx.local_id(vid);
317317

318-
if let ty::VariantKind::Dict = variant.kind() {
318+
if let ty::VariantKind::Struct = variant.kind() {
319319
// tuple-like enum variant fields aren't really items so
320320
// don't try to encode them.
321321
for field in &variant.fields {
@@ -328,7 +328,7 @@ fn encode_enum_variant_info<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
328328
encode_def_id_and_key(ecx, rbml_w, vid);
329329
encode_family(rbml_w, match variant.kind() {
330330
ty::VariantKind::Unit | ty::VariantKind::Tuple => 'v',
331-
ty::VariantKind::Dict => 'V'
331+
ty::VariantKind::Struct => 'V'
332332
});
333333
encode_name(rbml_w, variant.name);
334334
encode_parent_item(rbml_w, ecx.tcx.map.local_def_id(id));
@@ -1019,7 +1019,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
10191019
encode_attributes(rbml_w, &item.attrs);
10201020
encode_repr_attrs(rbml_w, ecx, &item.attrs);
10211021
for v in &enum_definition.variants {
1022-
encode_variant_id(rbml_w, ecx.tcx.map.local_def_id(v.node.def.id));
1022+
encode_variant_id(rbml_w, ecx.tcx.map.local_def_id(v.node.data.id));
10231023
}
10241024
encode_inlined_item(ecx, rbml_w, InlinedItemRef::Item(item));
10251025
encode_path(rbml_w, path);
@@ -1068,7 +1068,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
10681068
// Encode inherent implementations for this structure.
10691069
encode_inherent_implementations(ecx, rbml_w, def_id);
10701070

1071-
if struct_def.kind != hir::VariantKind::Dict {
1071+
if struct_def.kind != hir::VariantKind::Struct {
10721072
let ctor_did = ecx.tcx.map.local_def_id(struct_def.id);
10731073
rbml_w.wr_tagged_u64(tag_items_data_item_struct_ctor,
10741074
def_to_u64(ctor_did));
@@ -1081,7 +1081,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
10811081
}
10821082

10831083
// If this is a tuple-like struct, encode the type of the constructor.
1084-
if struct_def.kind != hir::VariantKind::Dict {
1084+
if struct_def.kind != hir::VariantKind::Struct {
10851085
encode_info_for_struct_ctor(ecx, rbml_w, item.name, struct_def.id, index, item.id);
10861086
}
10871087
}

src/librustc/middle/astencode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,11 +1316,11 @@ fn copy_item_types(dcx: &DecodeContext, ii: &InlinedItem, orig_did: DefId) {
13161316
{
13171317
debug!("astencode: copying variant {:?} => {:?}",
13181318
orig_variant.did, i_variant.node.id);
1319-
copy_item_type(dcx, i_variant.node.def.id, orig_variant.did);
1319+
copy_item_type(dcx, i_variant.node.data.id, orig_variant.did);
13201320
}
13211321
}
13221322
hir::ItemStruct(ref def, _) => {
1323-
if def.kind != hir::VariantKind::Dict {
1323+
if def.kind != hir::VariantKind::Struct {
13241324
let ctor_did = dcx.tcx.lookup_adt_def(orig_did)
13251325
.struct_variant().did;
13261326
debug!("astencode: copying ctor {:?} => {:?}", ctor_did,

src/librustc/middle/check_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
518518

519519
ty::TyEnum(adt, _) | ty::TyStruct(adt, _) => {
520520
let v = adt.variant_of_ctor(ctor);
521-
if let VariantKind::Dict = v.kind() {
521+
if let VariantKind::Struct = v.kind() {
522522
let field_pats: Vec<_> = v.fields.iter()
523523
.zip(pats)
524524
.filter(|&(_, ref pat)| pat.node != hir::PatWild(hir::PatWildSingle))

src/librustc/middle/check_static_recursion.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl<'a, 'ast: 'a> CheckItemRecursionVisitor<'a, 'ast> {
168168
let mut discriminant_map = self.discriminant_map.borrow_mut();
169169
match enum_definition.variants.first() {
170170
None => { return; }
171-
Some(variant) if discriminant_map.contains_key(&variant.node.def.id) => {
171+
Some(variant) if discriminant_map.contains_key(&variant.node.data.id) => {
172172
return;
173173
}
174174
_ => {}
@@ -177,7 +177,7 @@ impl<'a, 'ast: 'a> CheckItemRecursionVisitor<'a, 'ast> {
177177
// Go through all the variants.
178178
let mut variant_stack: Vec<ast::NodeId> = Vec::new();
179179
for variant in enum_definition.variants.iter().rev() {
180-
variant_stack.push(variant.node.def.id);
180+
variant_stack.push(variant.node.data.id);
181181
// When we find an expression, every variant currently on the stack
182182
// is affected by that expression.
183183
if let Some(ref expr) = variant.node.disr_expr {
@@ -208,7 +208,7 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'ast> {
208208

209209
fn visit_variant(&mut self, variant: &'ast hir::Variant,
210210
_: &'ast hir::Generics, _: ast::NodeId) {
211-
let variant_id = variant.node.def.id;
211+
let variant_id = variant.node.data.id;
212212
let maybe_expr;
213213
if let Some(get_expr) = self.discriminant_map.borrow().get(&variant_id) {
214214
// This is necessary because we need to let the `discriminant_map`

src/librustc/middle/const_eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn lookup_variant_by_id<'a>(tcx: &'a ty::ctxt,
6363
fn variant_expr<'a>(variants: &'a [P<hir::Variant>], id: ast::NodeId)
6464
-> Option<&'a Expr> {
6565
for variant in variants {
66-
if variant.node.def.id == id {
66+
if variant.node.data.id == id {
6767
return variant.node.disr_expr.as_ref().map(|e| &**e);
6868
}
6969
}

src/librustc/middle/dead.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
215215

216216
impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
217217

218-
fn visit_struct_def(&mut self, def: &hir::StructDef, _: ast::Name,
218+
fn visit_variant_data(&mut self, def: &hir::VariantData, _: ast::Name,
219219
_: &hir::Generics, _: ast::NodeId, _: codemap::Span) {
220220
let has_extern_repr = self.struct_has_extern_repr;
221221
let inherited_pub_visibility = self.inherited_pub_visibility;
@@ -339,7 +339,7 @@ impl<'v> Visitor<'v> for LifeSeeder {
339339
}
340340
match item.node {
341341
hir::ItemEnum(ref enum_def, _) if allow_dead_code => {
342-
self.worklist.extend(enum_def.variants.iter().map(|variant| variant.node.def.id));
342+
self.worklist.extend(enum_def.variants.iter().map(|variant| variant.node.data.id));
343343
}
344344
hir::ItemTrait(_, _, _, ref trait_items) => {
345345
for trait_item in trait_items {
@@ -426,7 +426,7 @@ fn find_live(tcx: &ty::ctxt,
426426

427427
fn get_struct_ctor_id(item: &hir::Item) -> Option<ast::NodeId> {
428428
match item.node {
429-
hir::ItemStruct(ref struct_def, _) if struct_def.kind != hir::VariantKind::Dict => {
429+
hir::ItemStruct(ref struct_def, _) if struct_def.kind != hir::VariantKind::Struct => {
430430
Some(struct_def.id)
431431
}
432432
_ => None
@@ -466,7 +466,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
466466
}
467467

468468
fn should_warn_about_variant(&mut self, variant: &hir::Variant_) -> bool {
469-
!self.symbol_is_live(variant.def.id, None)
469+
!self.symbol_is_live(variant.data.id, None)
470470
&& !has_allow_dead_code_or_lang_attr(&variant.attrs)
471471
}
472472

@@ -542,7 +542,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
542542
hir::ItemEnum(ref enum_def, _) => {
543543
for variant in &enum_def.variants {
544544
if self.should_warn_about_variant(&variant.node) {
545-
self.warn_dead_code(variant.node.def.id, variant.span,
545+
self.warn_dead_code(variant.node.data.id, variant.span,
546546
variant.node.name, "variant");
547547
}
548548
}

0 commit comments

Comments
 (0)