Skip to content

Commit

Permalink
rename ADTDef to AdtDef etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariel Ben-Yehuda committed Aug 7, 2015
1 parent 62cd3cc commit eedb1cc
Show file tree
Hide file tree
Showing 23 changed files with 164 additions and 145 deletions.
2 changes: 1 addition & 1 deletion src/librustc/metadata/csearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ pub fn get_trait_def<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId) -> ty::TraitDe
decoder::get_trait_def(&*cdata, def.node, tcx)
}

pub fn get_adt_def<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId) -> &'tcx ty::ADTDef_<'tcx, 'tcx> {
pub fn get_adt_def<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId) -> ty::AdtDefMaster<'tcx> {
let cstore = &tcx.sess.cstore;
let cdata = cstore.get_crate_data(def.krate);
decoder::get_adt_def(&cstore.intr, &*cdata, def.node, tcx)
Expand Down
30 changes: 15 additions & 15 deletions src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,12 @@ pub fn get_trait_def<'tcx>(cdata: Cmd,
pub fn get_adt_def<'tcx>(intr: &IdentInterner,
cdata: Cmd,
item_id: ast::NodeId,
tcx: &ty::ctxt<'tcx>) -> &'tcx ty::ADTDef_<'tcx, 'tcx>
tcx: &ty::ctxt<'tcx>) -> ty::AdtDefMaster<'tcx>
{
fn get_enum_variants<'tcx>(intr: &IdentInterner,
cdata: Cmd,
doc: rbml::Doc,
tcx: &ty::ctxt<'tcx>) -> Vec<ty::VariantDef_<'tcx, 'tcx>> {
tcx: &ty::ctxt<'tcx>) -> Vec<ty::VariantDefData<'tcx, 'tcx>> {
let mut disr_val = 0;
reader::tagged_docs(doc, tag_items_data_item_variant).map(|p| {
let did = translated_def_id(cdata, p);
Expand All @@ -410,7 +410,7 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
let disr = disr_val;
disr_val = disr_val.wrapping_add(1);

ty::VariantDef_ {
ty::VariantDefData {
did: did,
name: item_name(intr, item),
fields: get_variant_fields(intr, cdata, item, tcx),
Expand All @@ -421,29 +421,29 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
fn get_variant_fields<'tcx>(intr: &IdentInterner,
cdata: Cmd,
doc: rbml::Doc,
tcx: &ty::ctxt<'tcx>) -> Vec<ty::FieldDef_<'tcx, 'tcx>> {
tcx: &ty::ctxt<'tcx>) -> Vec<ty::FieldDefData<'tcx, 'tcx>> {
reader::tagged_docs(doc, tag_item_field).map(|f| {
let ff = item_family(f);
match ff {
PublicField | InheritedField => {},
_ => tcx.sess.bug(&format!("expected field, found {:?}", ff))
};
ty::FieldDef_::new(item_def_id(f, cdata),
item_name(intr, f),
struct_field_family_to_visibility(ff))
ty::FieldDefData::new(item_def_id(f, cdata),
item_name(intr, f),
struct_field_family_to_visibility(ff))
}).chain(reader::tagged_docs(doc, tag_item_unnamed_field).map(|f| {
let ff = item_family(f);
ty::FieldDef_::new(item_def_id(f, cdata),
special_idents::unnamed_field.name,
struct_field_family_to_visibility(ff))
ty::FieldDefData::new(item_def_id(f, cdata),
special_idents::unnamed_field.name,
struct_field_family_to_visibility(ff))
})).collect()
}
fn get_struct_variant<'tcx>(intr: &IdentInterner,
cdata: Cmd,
doc: rbml::Doc,
did: ast::DefId,
tcx: &ty::ctxt<'tcx>) -> ty::VariantDef_<'tcx, 'tcx> {
ty::VariantDef_ {
tcx: &ty::ctxt<'tcx>) -> ty::VariantDefData<'tcx, 'tcx> {
ty::VariantDefData {
did: did,
name: item_name(intr, doc),
fields: get_variant_fields(intr, cdata, doc, tcx),
Expand All @@ -454,9 +454,9 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
let doc = lookup_item(item_id, cdata.data());
let did = ast::DefId { krate: cdata.cnum, node: item_id };
let (kind, variants) = match item_family(doc) {
Enum => (ty::ADTKind::Enum,
Enum => (ty::AdtKind::Enum,
get_enum_variants(intr, cdata, doc, tcx)),
Struct => (ty::ADTKind::Struct,
Struct => (ty::AdtKind::Struct,
vec![get_struct_variant(intr, cdata, doc, did, tcx)]),
_ => tcx.sess.bug("get_adt_def called on a non-ADT")
};
Expand All @@ -467,7 +467,7 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
// to support recursive structures
for variant in &adt.variants {
if variant.kind() == ty::VariantKind::Tuple &&
adt.adt_kind() == ty::ADTKind::Enum {
adt.adt_kind() == ty::AdtKind::Enum {
// tuple-like enum variant fields aren't real items - get the types
// from the ctor.
debug!("evaluating the ctor-type of {:?}",
Expand Down
21 changes: 9 additions & 12 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ fn encode_parent_item(rbml_w: &mut Encoder, id: DefId) {
}

fn encode_struct_fields(rbml_w: &mut Encoder,
fields: &[ty::FieldDef],
variant: ty::VariantDef,
origin: DefId) {
for f in fields {
for f in &variant.fields {
if f.name == special_idents::unnamed_field.name {
rbml_w.start_tag(tag_item_unnamed_field);
} else {
Expand Down Expand Up @@ -315,14 +315,11 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
encode_stability(rbml_w, stab);

if let ty::VariantKind::Dict = variant.kind() {
let idx = encode_info_for_struct(ecx,
rbml_w,
&variant.fields,
index);
let idx = encode_info_for_struct(ecx, rbml_w, variant, index);
encode_index(rbml_w, idx, write_i64);
}

encode_struct_fields(rbml_w, &variant.fields, vid);
encode_struct_fields(rbml_w, variant, vid);

let specified_disr_val = variant.disr_val;
if specified_disr_val != disr_val {
Expand Down Expand Up @@ -630,15 +627,15 @@ fn encode_provided_source(rbml_w: &mut Encoder,
/* Returns an index of items in this class */
fn encode_info_for_struct<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
rbml_w: &mut Encoder,
fields: &[ty::FieldDef<'tcx>],
variant: ty::VariantDef<'tcx>,
global_index: &mut Vec<entry<i64>>)
-> Vec<entry<i64>> {
/* Each class has its own index, since different classes
may have fields with the same name */
let mut index = Vec::new();
/* We encode both private and public fields -- need to include
private fields to get the offsets right */
for field in fields {
for field in &variant.fields {
let nm = field.name;
let id = field.did.node;

Expand Down Expand Up @@ -1153,13 +1150,13 @@ fn encode_info_for_item(ecx: &EncodeContext,
}
ast::ItemStruct(ref struct_def, _) => {
let def = ecx.tcx.lookup_adt_def(def_id);
let fields = &def.struct_variant().fields;
let variant = def.struct_variant();

/* First, encode the fields
These come first because we need to write them to make
the index, and the index needs to be in the item for the
class itself */
let idx = encode_info_for_struct(ecx, rbml_w, &fields, index);
let idx = encode_info_for_struct(ecx, rbml_w, variant, index);

/* Index the class*/
add_to_index(item, rbml_w, index);
Expand All @@ -1181,7 +1178,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
/* Encode def_ids for each field and method
for methods, write all the stuff get_trait_method
needs to know*/
encode_struct_fields(rbml_w, &fields, def_id);
encode_struct_fields(rbml_w, variant, def_id);

encode_inlined_item(ecx, rbml_w, IIItemRef(item));

Expand Down
6 changes: 4 additions & 2 deletions src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,10 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
})
}

impl<'tcx> ADTDef<'tcx> {
fn variant_of_ctor(&'tcx self, ctor: &Constructor) -> &'tcx VariantDef<'tcx> {
impl<'tcx, 'container> ty::AdtDefData<'tcx, 'container> {
fn variant_of_ctor(&self,
ctor: &Constructor)
-> &VariantDefData<'tcx, 'container> {
match ctor {
&Variant(vid) => self.variant_with_id(vid),
_ => self.struct_variant()
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
// are properly handled.
self.walk_expr(with_expr);

fn contains_field_named(field: &ty::FieldDef,
fn contains_field_named(field: ty::FieldDef,
fields: &Vec<ast::Field>)
-> bool
{
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/traits/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ fn fundamental_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool
match ty.sty {
ty::TyBox(..) | ty::TyRef(..) =>
true,
ty::TyEnum(def, _) | ty::TyStruct(def, _) => def.is_fundamental()
,
ty::TyEnum(def, _) | ty::TyStruct(def, _) =>
def.is_fundamental(),
ty::TyTrait(ref data) =>
tcx.has_attr(data.principal_def_id(), "fundamental"),
_ =>
Expand Down
Loading

0 comments on commit eedb1cc

Please sign in to comment.