did: did,
name: item_name(intr, item),
fields: get_variant_fields(intr, cdata, item, tcx),
- ctor_id: did,
disr_val: disr
}
}).collect()
cdata: Cmd,
doc: rbml::Doc,
did: DefId,
- ctor_id: DefId,
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),
- ctor_id: ctor_id,
disr_val: 0
}
}
reader::maybe_get_doc(doc, tag_items_data_item_struct_ctor).
map_or(did, |ctor_doc| translated_def_id(cdata, ctor_doc));
(ty::AdtKind::Struct,
- vec![get_struct_variant(intr, cdata, doc, did, ctor_did, tcx)])
+ vec![get_struct_variant(intr, cdata, doc, ctor_did, tcx)])
}
_ => tcx.sess.bug(
&format!("get_adt_def called on a non-ADT {:?} - {:?}",
for (i_variant, orig_variant) in
def.variants.iter().zip(orig_def.variants.iter())
{
+ debug!("astencode: copying variant {:?} => {:?}",
+ orig_variant.did, i_variant.node.id);
copy_item_type(dcx, i_variant.node.id, orig_variant.did);
}
}
hir::ItemStruct(ref def, _) => {
if let Some(ctor_id) = def.ctor_id {
let ctor_did = dcx.tcx.lookup_adt_def(orig_did)
- .struct_variant().ctor_id;
- debug!("copying ctor {:?}", ctor_did);
+ .struct_variant().did;
+ debug!("astencode: copying ctor {:?} => {:?}", ctor_did,
+ ctor_id);
copy_item_type(dcx, ctor_id, ctor_did);
}
}
pub type FieldDefMaster<'tcx> = &'tcx FieldDefData<'tcx, 'tcx>;
pub struct VariantDefData<'tcx, 'container: 'tcx> {
+ /// The variant's DefId. If this is a tuple-like struct,
+ /// this is the DefId of the struct's ctor.
pub did: DefId,
pub name: Name, // struct's name if this is a struct
pub disr_val: Disr,
pub fields: Vec<FieldDefData<'tcx, 'container>>,
- /// The DefId of the variant's ctor (unless the variant is a
- /// tuple-like struct variant, this is just the variant's def-id).
- pub ctor_id: DefId
}
pub struct FieldDefData<'tcx, 'container: 'tcx> {
did: DefId,
name: ast::Name,
disr_val: ty::Disr,
- def: &hir::StructDef,
- ctor_id: DefId) -> ty::VariantDefData<'tcx, 'tcx> {
+ def: &hir::StructDef) -> ty::VariantDefData<'tcx, 'tcx> {
let mut seen_fields: FnvHashMap<ast::Name, Span> = FnvHashMap();
let fields = def.fields.iter().map(|f| {
let fid = tcx.map.local_def_id(f.node.id);
did: did,
name: name,
disr_val: disr_val,
- fields: fields,
- ctor_id: ctor_id
+ fields: fields
}
}
tcx.intern_adt_def(
did,
ty::AdtKind::Struct,
- vec![convert_struct_variant(tcx, did, it.name, 0, def, ctor_id)]
+ vec![convert_struct_variant(tcx, ctor_id, it.name, 0, def)]
)
}
special_idents::unnamed_field.name,
hir::Visibility::Public
)
- }).collect(),
- ctor_id: did
+ }).collect()
}
}
hir::StructVariantKind(ref def) => {
- convert_struct_variant(tcx, did, name, disr, &def, did)
+ convert_struct_variant(tcx, did, name, disr, &def)
}
}
}