rename ADTDef to AdtDef etc.
This commit is contained in:
parent
62cd3cc46b
commit
eedb1cc576
23 changed files with 164 additions and 145 deletions
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
@ -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),
|
||||
|
@ -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),
|
||||
|
@ -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")
|
||||
};
|
||||
|
@ -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 {:?}",
|
||||
|
|
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -630,7 +627,7 @@ 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
|
||||
|
@ -638,7 +635,7 @@ fn encode_info_for_struct<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
|
|||
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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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"),
|
||||
_ =>
|
||||
|
|
|
@ -638,7 +638,7 @@ pub struct CtxtArenas<'tcx> {
|
|||
|
||||
// references
|
||||
trait_defs: TypedArena<TraitDef<'tcx>>,
|
||||
adt_defs: TypedArena<ADTDef_<'tcx, 'tcx>>,
|
||||
adt_defs: TypedArena<AdtDefData<'tcx, 'tcx>>,
|
||||
}
|
||||
|
||||
impl<'tcx> CtxtArenas<'tcx> {
|
||||
|
@ -766,7 +766,7 @@ pub struct ctxt<'tcx> {
|
|||
|
||||
pub impl_trait_refs: RefCell<DefIdMap<Option<TraitRef<'tcx>>>>,
|
||||
pub trait_defs: RefCell<DefIdMap<&'tcx TraitDef<'tcx>>>,
|
||||
pub adt_defs: RefCell<DefIdMap<&'tcx ADTDef_<'tcx, 'tcx>>>,
|
||||
pub adt_defs: RefCell<DefIdMap<AdtDefMaster<'tcx>>>,
|
||||
|
||||
/// Maps from the def-id of an item (trait/struct/enum/fn) to its
|
||||
/// associated predicates.
|
||||
|
@ -937,10 +937,10 @@ impl<'tcx> ctxt<'tcx> {
|
|||
|
||||
pub fn intern_adt_def(&self,
|
||||
did: DefId,
|
||||
kind: ADTKind,
|
||||
variants: Vec<VariantDef_<'tcx, 'tcx>>)
|
||||
-> &'tcx ADTDef_<'tcx, 'tcx> {
|
||||
let def = ADTDef_::new(self, did, kind, variants);
|
||||
kind: AdtKind,
|
||||
variants: Vec<VariantDefData<'tcx, 'tcx>>)
|
||||
-> AdtDefMaster<'tcx> {
|
||||
let def = AdtDefData::new(self, did, kind, variants);
|
||||
let interned = self.arenas.adt_defs.alloc(def);
|
||||
// this will need a transmute when reverse-variance is removed
|
||||
self.adt_defs.borrow_mut().insert(did, interned);
|
||||
|
@ -1746,12 +1746,12 @@ pub enum TypeVariants<'tcx> {
|
|||
/// from the tcx, use the `NodeId` from the `ast::Ty` and look it up in
|
||||
/// the `ast_ty_to_ty_cache`. This is probably true for `TyStruct` as
|
||||
/// well.
|
||||
TyEnum(&'tcx ADTDef<'tcx>, &'tcx Substs<'tcx>),
|
||||
TyEnum(AdtDef<'tcx>, &'tcx Substs<'tcx>),
|
||||
|
||||
/// A structure type, defined with `struct`.
|
||||
///
|
||||
/// See warning about substitutions for enumerated types.
|
||||
TyStruct(&'tcx ADTDef<'tcx>, &'tcx Substs<'tcx>),
|
||||
TyStruct(AdtDef<'tcx>, &'tcx Substs<'tcx>),
|
||||
|
||||
/// `Box<T>`; this is nominally a struct in the documentation, but is
|
||||
/// special-cased internally. For example, it is possible to implicitly
|
||||
|
@ -3177,7 +3177,7 @@ impl<'tcx> TraitDef<'tcx> {
|
|||
}
|
||||
|
||||
bitflags! {
|
||||
flags ADTFlags: u32 {
|
||||
flags AdtFlags: u32 {
|
||||
const NO_ADT_FLAGS = 0,
|
||||
const IS_ENUM = 1 << 0,
|
||||
const IS_DTORCK = 1 << 1, // is this a dtorck type?
|
||||
|
@ -3188,18 +3188,23 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
pub type ADTDef<'tcx> = ADTDef_<'tcx, 'static>;
|
||||
pub type VariantDef<'tcx> = VariantDef_<'tcx, 'static>;
|
||||
pub type FieldDef<'tcx> = FieldDef_<'tcx, 'static>;
|
||||
pub type AdtDef<'tcx> = &'tcx AdtDefData<'tcx, 'static>;
|
||||
pub type VariantDef<'tcx> = &'tcx VariantDefData<'tcx, 'static>;
|
||||
pub type FieldDef<'tcx> = &'tcx FieldDefData<'tcx, 'static>;
|
||||
|
||||
pub struct VariantDef_<'tcx, 'container: 'tcx> {
|
||||
// See comment on AdtDefData for explanation
|
||||
pub type AdtDefMaster<'tcx> = &'tcx AdtDefData<'tcx, 'tcx>;
|
||||
pub type VariantDefMaster<'tcx> = &'tcx VariantDefData<'tcx, 'tcx>;
|
||||
pub type FieldDefMaster<'tcx> = &'tcx FieldDefData<'tcx, 'tcx>;
|
||||
|
||||
pub struct VariantDefData<'tcx, 'container: 'tcx> {
|
||||
pub did: DefId,
|
||||
pub name: Name, // struct's name if this is a struct
|
||||
pub disr_val: Disr,
|
||||
pub fields: Vec<FieldDef_<'tcx, 'container>>
|
||||
pub fields: Vec<FieldDefData<'tcx, 'container>>
|
||||
}
|
||||
|
||||
pub struct FieldDef_<'tcx, 'container: 'tcx> {
|
||||
pub struct FieldDefData<'tcx, 'container: 'tcx> {
|
||||
/// The field's DefId. NOTE: the fields of tuple-like enum variants
|
||||
/// are not real items, and don't have entries in tcache etc.
|
||||
pub did: DefId,
|
||||
|
@ -3208,7 +3213,7 @@ pub struct FieldDef_<'tcx, 'container: 'tcx> {
|
|||
pub name: Name,
|
||||
pub vis: ast::Visibility,
|
||||
/// TyIVar is used here to allow for variance (see the doc at
|
||||
/// ADTDef_).
|
||||
/// AdtDefData).
|
||||
ty: TyIVar<'tcx, 'container>
|
||||
}
|
||||
|
||||
|
@ -3221,60 +3226,60 @@ pub struct FieldDef_<'tcx, 'container: 'tcx> {
|
|||
/// needs 2 lifetimes: the traditional variant lifetime ('tcx)
|
||||
/// bounding the lifetime of the inner types is of course necessary.
|
||||
/// However, it is not sufficient - types from a child tcx must
|
||||
/// not be leaked into the master tcx by being stored in an ADTDef_.
|
||||
/// not be leaked into the master tcx by being stored in an AdtDefData.
|
||||
///
|
||||
/// The 'container lifetime ensures that by outliving the container
|
||||
/// tcx and preventing shorter-lived types from being inserted. When
|
||||
/// write access is not needed, the 'container lifetime can be
|
||||
/// erased to 'static, which can be done by the ADTDef wrapper.
|
||||
pub struct ADTDef_<'tcx, 'container: 'tcx> {
|
||||
/// erased to 'static, which can be done by the AdtDef wrapper.
|
||||
pub struct AdtDefData<'tcx, 'container: 'tcx> {
|
||||
pub did: DefId,
|
||||
pub variants: Vec<VariantDef_<'tcx, 'container>>,
|
||||
flags: Cell<ADTFlags>,
|
||||
pub variants: Vec<VariantDefData<'tcx, 'container>>,
|
||||
flags: Cell<AdtFlags>,
|
||||
}
|
||||
|
||||
impl<'tcx, 'container> PartialEq for ADTDef_<'tcx, 'container> {
|
||||
// ADTDef are always interned and this is part of TyS equality
|
||||
impl<'tcx, 'container> PartialEq for AdtDefData<'tcx, 'container> {
|
||||
// AdtDefData are always interned and this is part of TyS equality
|
||||
#[inline]
|
||||
fn eq(&self, other: &Self) -> bool { self as *const _ == other as *const _ }
|
||||
}
|
||||
|
||||
impl<'tcx, 'container> Eq for ADTDef_<'tcx, 'container> {}
|
||||
impl<'tcx, 'container> Eq for AdtDefData<'tcx, 'container> {}
|
||||
|
||||
impl<'tcx, 'container> Hash for ADTDef_<'tcx, 'container> {
|
||||
impl<'tcx, 'container> Hash for AdtDefData<'tcx, 'container> {
|
||||
#[inline]
|
||||
fn hash<H: Hasher>(&self, s: &mut H) {
|
||||
(self as *const ADTDef).hash(s)
|
||||
(self as *const AdtDefData).hash(s)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum ADTKind { Struct, Enum }
|
||||
pub enum AdtKind { Struct, Enum }
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum VariantKind { Dict, Tuple, Unit }
|
||||
|
||||
impl<'tcx, 'container> ADTDef_<'tcx, 'container> {
|
||||
impl<'tcx, 'container> AdtDefData<'tcx, 'container> {
|
||||
fn new(tcx: &ctxt<'tcx>,
|
||||
did: DefId,
|
||||
kind: ADTKind,
|
||||
variants: Vec<VariantDef_<'tcx, 'container>>) -> Self {
|
||||
let mut flags = ADTFlags::NO_ADT_FLAGS;
|
||||
kind: AdtKind,
|
||||
variants: Vec<VariantDefData<'tcx, 'container>>) -> Self {
|
||||
let mut flags = AdtFlags::NO_ADT_FLAGS;
|
||||
let attrs = tcx.get_attrs(did);
|
||||
if attrs.iter().any(|item| item.check_name("fundamental")) {
|
||||
flags = flags | ADTFlags::IS_FUNDAMENTAL;
|
||||
flags = flags | AdtFlags::IS_FUNDAMENTAL;
|
||||
}
|
||||
if attrs.iter().any(|item| item.check_name("simd")) {
|
||||
flags = flags | ADTFlags::IS_SIMD;
|
||||
flags = flags | AdtFlags::IS_SIMD;
|
||||
}
|
||||
if Some(did) == tcx.lang_items.phantom_data() {
|
||||
flags = flags | ADTFlags::IS_PHANTOM_DATA;
|
||||
flags = flags | AdtFlags::IS_PHANTOM_DATA;
|
||||
}
|
||||
if let ADTKind::Enum = kind {
|
||||
flags = flags | ADTFlags::IS_ENUM;
|
||||
if let AdtKind::Enum = kind {
|
||||
flags = flags | AdtFlags::IS_ENUM;
|
||||
}
|
||||
ADTDef {
|
||||
AdtDefData {
|
||||
did: did,
|
||||
variants: variants,
|
||||
flags: Cell::new(flags),
|
||||
|
@ -3283,18 +3288,18 @@ impl<'tcx, 'container> ADTDef_<'tcx, 'container> {
|
|||
|
||||
fn calculate_dtorck(&'tcx self, tcx: &ctxt<'tcx>) {
|
||||
if tcx.is_adt_dtorck(self) {
|
||||
self.flags.set(self.flags.get() | ADTFlags::IS_DTORCK);
|
||||
self.flags.set(self.flags.get() | AdtFlags::IS_DTORCK);
|
||||
}
|
||||
self.flags.set(self.flags.get() | ADTFlags::IS_DTORCK_VALID)
|
||||
self.flags.set(self.flags.get() | AdtFlags::IS_DTORCK_VALID)
|
||||
}
|
||||
|
||||
/// Returns the kind of the ADT - Struct or Enum.
|
||||
#[inline]
|
||||
pub fn adt_kind(&self) -> ADTKind {
|
||||
if self.flags.get().intersects(ADTFlags::IS_ENUM) {
|
||||
ADTKind::Enum
|
||||
pub fn adt_kind(&self) -> AdtKind {
|
||||
if self.flags.get().intersects(AdtFlags::IS_ENUM) {
|
||||
AdtKind::Enum
|
||||
} else {
|
||||
ADTKind::Struct
|
||||
AdtKind::Struct
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3303,28 +3308,28 @@ impl<'tcx, 'container> ADTDef_<'tcx, 'container> {
|
|||
/// alive; Otherwise, only the contents are required to be.
|
||||
#[inline]
|
||||
pub fn is_dtorck(&'tcx self, tcx: &ctxt<'tcx>) -> bool {
|
||||
if !self.flags.get().intersects(ADTFlags::IS_DTORCK_VALID) {
|
||||
if !self.flags.get().intersects(AdtFlags::IS_DTORCK_VALID) {
|
||||
self.calculate_dtorck(tcx)
|
||||
}
|
||||
self.flags.get().intersects(ADTFlags::IS_DTORCK)
|
||||
self.flags.get().intersects(AdtFlags::IS_DTORCK)
|
||||
}
|
||||
|
||||
/// Returns whether this type is #[fundamental] for the purposes
|
||||
/// of coherence checking.
|
||||
#[inline]
|
||||
pub fn is_fundamental(&self) -> bool {
|
||||
self.flags.get().intersects(ADTFlags::IS_FUNDAMENTAL)
|
||||
self.flags.get().intersects(AdtFlags::IS_FUNDAMENTAL)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_simd(&self) -> bool {
|
||||
self.flags.get().intersects(ADTFlags::IS_SIMD)
|
||||
self.flags.get().intersects(AdtFlags::IS_SIMD)
|
||||
}
|
||||
|
||||
/// Returns true if this is PhantomData<T>.
|
||||
#[inline]
|
||||
pub fn is_phantom_data(&self) -> bool {
|
||||
self.flags.get().intersects(ADTFlags::IS_PHANTOM_DATA)
|
||||
self.flags.get().intersects(AdtFlags::IS_PHANTOM_DATA)
|
||||
}
|
||||
|
||||
/// Returns whether this type has a destructor.
|
||||
|
@ -3334,8 +3339,8 @@ impl<'tcx, 'container> ADTDef_<'tcx, 'container> {
|
|||
|
||||
/// Asserts this is a struct and returns the struct's unique
|
||||
/// variant.
|
||||
pub fn struct_variant(&self) -> &ty::VariantDef_<'tcx, 'container> {
|
||||
assert!(self.adt_kind() == ADTKind::Struct);
|
||||
pub fn struct_variant(&self) -> &VariantDefData<'tcx, 'container> {
|
||||
assert!(self.adt_kind() == AdtKind::Struct);
|
||||
&self.variants[0]
|
||||
}
|
||||
|
||||
|
@ -3354,12 +3359,12 @@ impl<'tcx, 'container> ADTDef_<'tcx, 'container> {
|
|||
#[inline]
|
||||
pub fn all_fields(&self) ->
|
||||
iter::FlatMap<
|
||||
slice::Iter<VariantDef_<'tcx, 'container>>,
|
||||
slice::Iter<FieldDef_<'tcx, 'container>>,
|
||||
for<'s> fn(&'s VariantDef_<'tcx, 'container>)
|
||||
-> slice::Iter<'s, FieldDef_<'tcx, 'container>>
|
||||
slice::Iter<VariantDefData<'tcx, 'container>>,
|
||||
slice::Iter<FieldDefData<'tcx, 'container>>,
|
||||
for<'s> fn(&'s VariantDefData<'tcx, 'container>)
|
||||
-> slice::Iter<'s, FieldDefData<'tcx, 'container>>
|
||||
> {
|
||||
self.variants.iter().flat_map(VariantDef_::fields_iter)
|
||||
self.variants.iter().flat_map(VariantDefData::fields_iter)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -3377,14 +3382,14 @@ impl<'tcx, 'container> ADTDef_<'tcx, 'container> {
|
|||
self.variants.iter().all(|v| v.fields.is_empty())
|
||||
}
|
||||
|
||||
pub fn variant_with_id(&self, vid: DefId) -> &VariantDef_<'tcx, 'container> {
|
||||
pub fn variant_with_id(&self, vid: DefId) -> &VariantDefData<'tcx, 'container> {
|
||||
self.variants
|
||||
.iter()
|
||||
.find(|v| v.did == vid)
|
||||
.expect("variant_with_id: unknown variant")
|
||||
}
|
||||
|
||||
pub fn variant_of_def(&self, def: def::Def) -> &VariantDef_<'tcx, 'container> {
|
||||
pub fn variant_of_def(&self, def: def::Def) -> &VariantDefData<'tcx, 'container> {
|
||||
match def {
|
||||
def::DefVariant(_, vid, _) => self.variant_with_id(vid),
|
||||
def::DefStruct(..) | def::DefTy(..) => self.struct_variant(),
|
||||
|
@ -3393,16 +3398,16 @@ impl<'tcx, 'container> ADTDef_<'tcx, 'container> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx, 'container> VariantDef_<'tcx, 'container> {
|
||||
impl<'tcx, 'container> VariantDefData<'tcx, 'container> {
|
||||
#[inline]
|
||||
fn fields_iter(&self) -> slice::Iter<FieldDef_<'tcx, 'container>> {
|
||||
fn fields_iter(&self) -> slice::Iter<FieldDefData<'tcx, 'container>> {
|
||||
self.fields.iter()
|
||||
}
|
||||
|
||||
pub fn kind(&self) -> VariantKind {
|
||||
match self.fields.get(0) {
|
||||
None => VariantKind::Unit,
|
||||
Some(&FieldDef_ { name, .. }) if name == special_idents::unnamed_field.name => {
|
||||
Some(&FieldDefData { name, .. }) if name == special_idents::unnamed_field.name => {
|
||||
VariantKind::Tuple
|
||||
}
|
||||
Some(_) => VariantKind::Dict
|
||||
|
@ -3414,21 +3419,23 @@ impl<'tcx, 'container> VariantDef_<'tcx, 'container> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn find_field_named(&self, name: ast::Name) -> Option<&FieldDef_<'tcx, 'container>> {
|
||||
pub fn find_field_named(&self,
|
||||
name: ast::Name)
|
||||
-> Option<&FieldDefData<'tcx, 'container>> {
|
||||
self.fields.iter().find(|f| f.name == name)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn field_named(&self, name: ast::Name) -> &FieldDef_<'tcx, 'container> {
|
||||
pub fn field_named(&self, name: ast::Name) -> &FieldDefData<'tcx, 'container> {
|
||||
self.find_field_named(name).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, 'container> FieldDef_<'tcx, 'container> {
|
||||
impl<'tcx, 'container> FieldDefData<'tcx, 'container> {
|
||||
pub fn new(did: DefId,
|
||||
name: Name,
|
||||
vis: ast::Visibility) -> Self {
|
||||
FieldDef_ {
|
||||
FieldDefData {
|
||||
did: did,
|
||||
name: name,
|
||||
vis: vis,
|
||||
|
@ -3934,7 +3941,7 @@ impl<'tcx> ctxt<'tcx> {
|
|||
self.mk_imm_ref(self.mk_region(ty::ReStatic), self.mk_str())
|
||||
}
|
||||
|
||||
pub fn mk_enum(&self, def: &'tcx ADTDef<'tcx>, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
||||
pub fn mk_enum(&self, def: AdtDef<'tcx>, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
||||
// take a copy of substs so that we own the vectors inside
|
||||
self.mk_ty(TyEnum(def, substs))
|
||||
}
|
||||
|
@ -4036,7 +4043,7 @@ impl<'tcx> ctxt<'tcx> {
|
|||
self.mk_ty(TyProjection(inner))
|
||||
}
|
||||
|
||||
pub fn mk_struct(&self, def: &'tcx ADTDef<'tcx>, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
||||
pub fn mk_struct(&self, def: AdtDef<'tcx>, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
|
||||
// take a copy of substs so that we own the vectors inside
|
||||
self.mk_ty(TyStruct(def, substs))
|
||||
}
|
||||
|
@ -4327,7 +4334,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn ty_adt_def(&self) -> Option<&'tcx ADTDef<'tcx>> {
|
||||
pub fn ty_adt_def(&self) -> Option<AdtDef<'tcx>> {
|
||||
match self.sty {
|
||||
TyStruct(adt, _) | TyEnum(adt, _) => Some(adt),
|
||||
_ => None
|
||||
|
@ -4677,7 +4684,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
|
||||
// True if instantiating an instance of `r_ty` requires an instance of `r_ty`.
|
||||
pub fn is_instantiable(&'tcx self, cx: &ctxt<'tcx>) -> bool {
|
||||
fn type_requires<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<&'tcx ADTDef<'tcx>>,
|
||||
fn type_requires<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<AdtDef<'tcx>>,
|
||||
r_ty: Ty<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
debug!("type_requires({:?}, {:?})?",
|
||||
r_ty, ty);
|
||||
|
@ -4689,7 +4696,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
return r;
|
||||
}
|
||||
|
||||
fn subtypes_require<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<&'tcx ADTDef<'tcx>>,
|
||||
fn subtypes_require<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<AdtDef<'tcx>>,
|
||||
r_ty: Ty<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
debug!("subtypes_require({:?}, {:?})?",
|
||||
r_ty, ty);
|
||||
|
@ -4826,7 +4833,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn same_struct_or_enum<'tcx>(ty: Ty<'tcx>, def: &'tcx ADTDef<'tcx>) -> bool {
|
||||
fn same_struct_or_enum<'tcx>(ty: Ty<'tcx>, def: AdtDef<'tcx>) -> bool {
|
||||
match ty.sty {
|
||||
TyStruct(ty_def, _) | TyEnum(ty_def, _) => {
|
||||
ty_def == def
|
||||
|
@ -5969,14 +5976,23 @@ impl<'tcx> ctxt<'tcx> {
|
|||
)
|
||||
}
|
||||
|
||||
/// Given the did of a trait, returns its canonical trait ref.
|
||||
pub fn lookup_adt_def(&self, did: ast::DefId) -> &'tcx ADTDef_<'tcx, 'tcx> {
|
||||
/// Given the did of an ADT, return a master reference to its
|
||||
/// definition. Unless you are planning on fulfilling the ADT's fields,
|
||||
/// use lookup_adt_def instead.
|
||||
pub fn lookup_adt_def_master(&self, did: ast::DefId) -> AdtDefMaster<'tcx> {
|
||||
lookup_locally_or_in_crate_store(
|
||||
"adt_defs", did, &self.adt_defs,
|
||||
|| csearch::get_adt_def(self, did)
|
||||
)
|
||||
}
|
||||
|
||||
/// Given the did of an ADT, return a reference to its definition.
|
||||
pub fn lookup_adt_def(&self, did: ast::DefId) -> AdtDef<'tcx> {
|
||||
// when reverse-variance goes away, a transmute::<AdtDefMaster,AdtDef>
|
||||
// woud be needed here.
|
||||
self.lookup_adt_def_master(did)
|
||||
}
|
||||
|
||||
/// Given the did of an item, returns its full set of predicates.
|
||||
pub fn lookup_predicates(&self, did: ast::DefId) -> GenericPredicates<'tcx> {
|
||||
lookup_locally_or_in_crate_store(
|
||||
|
@ -6610,7 +6626,7 @@ impl<'tcx> ctxt<'tcx> {
|
|||
|
||||
/// Returns true if this ADT is a dtorck type, i.e. whether it being
|
||||
/// safe for destruction requires it to be alive
|
||||
fn is_adt_dtorck(&self, adt: &'tcx ADTDef<'tcx>) -> bool {
|
||||
fn is_adt_dtorck(&self, adt: AdtDef<'tcx>) -> bool {
|
||||
let dtor_method = match self.destructor_for_type.borrow().get(&adt.did) {
|
||||
Some(dtor) => *dtor,
|
||||
None => return false
|
||||
|
|
|
@ -366,7 +366,7 @@ impl<'tcx> fmt::Debug for ty::TraitDef<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> fmt::Debug for ty::ADTDef<'tcx> {
|
||||
impl<'tcx, 'container> fmt::Debug for ty::AdtDefData<'tcx, 'container> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
ty::tls::with(|tcx| {
|
||||
write!(f, "{}", tcx.item_path_str(self.did))
|
||||
|
|
|
@ -20,6 +20,10 @@ use std::cell::Cell;
|
|||
/// if you attempt to read the value before it has been set. It is also
|
||||
/// not `Sync`, but may be extended in the future to be usable as a true
|
||||
/// concurrency type.
|
||||
///
|
||||
/// The `T: Copy` bound is not strictly needed, but it is required by
|
||||
/// Cell (so removing it would require using UnsafeCell), and it
|
||||
/// suffices for the current purposes.
|
||||
#[derive(PartialEq)]
|
||||
pub struct Ivar<T: Copy> {
|
||||
data: Cell<Option<T>>
|
||||
|
|
|
@ -413,7 +413,7 @@ enum FfiResult {
|
|||
/// expanded to cover NonZero raw pointers and newtypes.
|
||||
/// FIXME: This duplicates code in trans.
|
||||
fn is_repr_nullable_ptr<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
def: &ty::ADTDef<'tcx>,
|
||||
def: ty::AdtDef<'tcx>,
|
||||
substs: &Substs<'tcx>)
|
||||
-> bool {
|
||||
if def.variants.len() == 2 {
|
||||
|
|
|
@ -687,8 +687,8 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
|||
// Checks that a field is in scope.
|
||||
fn check_field(&mut self,
|
||||
span: Span,
|
||||
def: &'tcx ty::ADTDef<'tcx>,
|
||||
v: &'tcx ty::VariantDef<'tcx>,
|
||||
def: ty::AdtDef<'tcx>,
|
||||
v: ty::VariantDef<'tcx>,
|
||||
name: FieldName) {
|
||||
let field = match name {
|
||||
NamedField(f_name) => {
|
||||
|
@ -703,10 +703,10 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
let struct_desc = match def.adt_kind() {
|
||||
ty::ADTKind::Struct =>
|
||||
ty::AdtKind::Struct =>
|
||||
format!("struct `{}`", self.tcx.item_path_str(def.did)),
|
||||
// struct variant fields have inherited visibility
|
||||
ty::ADTKind::Enum => return
|
||||
ty::AdtKind::Enum => return
|
||||
};
|
||||
let msg = match name {
|
||||
NamedField(name) => format!("field `{}` of {} is private",
|
||||
|
|
|
@ -742,7 +742,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
|
|||
ex: &ast::Expr,
|
||||
path: &ast::Path,
|
||||
fields: &Vec<ast::Field>,
|
||||
variant: &ty::VariantDef,
|
||||
variant: ty::VariantDef,
|
||||
base: &Option<P<ast::Expr>>) {
|
||||
if generated_code(path.span) {
|
||||
return
|
||||
|
|
|
@ -613,7 +613,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
|
||||
pub fn get_field_ref_data(&self,
|
||||
field_ref: &ast::Field,
|
||||
variant: &ty::VariantDef,
|
||||
variant: ty::VariantDef,
|
||||
parent: NodeId)
|
||||
-> VariableRefData {
|
||||
let f = variant.field_named(field_ref.ident.node.name);
|
||||
|
|
|
@ -527,7 +527,7 @@ impl<'tcx> Case<'tcx> {
|
|||
}
|
||||
|
||||
fn get_cases<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
adt: &ty::ADTDef<'tcx>,
|
||||
adt: ty::AdtDef<'tcx>,
|
||||
substs: &subst::Substs<'tcx>)
|
||||
-> Vec<Case<'tcx>> {
|
||||
adt.variants.iter().map(|vi| {
|
||||
|
|
|
@ -386,7 +386,7 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
|||
fn iter_variant<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
||||
repr: &adt::Repr<'tcx>,
|
||||
av: ValueRef,
|
||||
variant: &ty::VariantDef<'tcx>,
|
||||
variant: ty::VariantDef<'tcx>,
|
||||
substs: &Substs<'tcx>,
|
||||
f: &mut F)
|
||||
-> Block<'blk, 'tcx> where
|
||||
|
|
|
@ -1242,7 +1242,7 @@ pub fn langcall(bcx: Block,
|
|||
/// Return the VariantDef corresponding to an inlined variant node
|
||||
pub fn inlined_variant_def<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
inlined_vid: ast::NodeId)
|
||||
-> &'tcx ty::VariantDef<'tcx>
|
||||
-> ty::VariantDef<'tcx>
|
||||
{
|
||||
|
||||
let ctor_ty = ccx.tcx().node_id_to_type(inlined_vid);
|
||||
|
|
|
@ -1094,7 +1094,7 @@ impl<'tcx> MemberDescriptionFactory<'tcx> {
|
|||
|
||||
// Creates MemberDescriptions for the fields of a struct
|
||||
struct StructMemberDescriptionFactory<'tcx> {
|
||||
variant: &'tcx ty::VariantDef<'tcx>,
|
||||
variant: ty::VariantDef<'tcx>,
|
||||
substs: &'tcx subst::Substs<'tcx>,
|
||||
is_simd: bool,
|
||||
span: Span,
|
||||
|
@ -1489,7 +1489,7 @@ enum EnumDiscriminantInfo {
|
|||
fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
enum_type: Ty<'tcx>,
|
||||
struct_def: &adt::Struct<'tcx>,
|
||||
variant: &ty::VariantDef<'tcx>,
|
||||
variant: ty::VariantDef<'tcx>,
|
||||
discriminant_info: EnumDiscriminantInfo,
|
||||
containing_scope: DIScope,
|
||||
span: Span)
|
||||
|
|
|
@ -291,7 +291,7 @@ pub fn apply_param_substs<'tcx,T>(tcx: &ty::ctxt<'tcx>,
|
|||
/// Returns the normalized type of a struct field
|
||||
pub fn field_ty<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
param_substs: &Substs<'tcx>,
|
||||
f: &ty::FieldDef<'tcx>)
|
||||
f: ty::FieldDef<'tcx>)
|
||||
-> Ty<'tcx>
|
||||
{
|
||||
normalize_associated_type(tcx, &f.ty(tcx, param_substs))
|
||||
|
|
|
@ -717,7 +717,7 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||
pub fn check_struct_pat_fields<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
||||
span: Span,
|
||||
fields: &'tcx [Spanned<ast::FieldPat>],
|
||||
variant: &ty::VariantDef<'tcx>,
|
||||
variant: ty::VariantDef<'tcx>,
|
||||
substs: &Substs<'tcx>,
|
||||
etc: bool) {
|
||||
let tcx = pcx.fcx.ccx.tcx;
|
||||
|
|
|
@ -289,10 +289,10 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>
|
|||
TypeContext::ADT { def_id, variant, field, field_index } => {
|
||||
let adt = tcx.lookup_adt_def(def_id);
|
||||
let variant_name = match adt.adt_kind() {
|
||||
ty::ADTKind::Enum => format!("enum {} variant {}",
|
||||
ty::AdtKind::Enum => format!("enum {} variant {}",
|
||||
tcx.item_path_str(def_id),
|
||||
variant),
|
||||
ty::ADTKind::Struct => format!("struct {}",
|
||||
ty::AdtKind::Struct => format!("struct {}",
|
||||
tcx.item_path_str(def_id))
|
||||
};
|
||||
let field_name = if field == special_idents::unnamed_field.name {
|
||||
|
|
|
@ -1677,7 +1677,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// FIXME(arielb1): use this instead of field.ty everywhere
|
||||
pub fn field_ty(&self,
|
||||
span: Span,
|
||||
field: &ty::FieldDef<'tcx>,
|
||||
field: ty::FieldDef<'tcx>,
|
||||
substs: &Substs<'tcx>)
|
||||
-> Ty<'tcx>
|
||||
{
|
||||
|
@ -2913,7 +2913,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
}
|
||||
|
||||
// displays hints about the closest matches in field names
|
||||
fn suggest_field_names<'tcx>(variant: &ty::VariantDef<'tcx>,
|
||||
fn suggest_field_names<'tcx>(variant: ty::VariantDef<'tcx>,
|
||||
field: &ast::SpannedIdent,
|
||||
tcx: &ty::ctxt<'tcx>,
|
||||
skip : Vec<InternedString>) {
|
||||
|
@ -3011,7 +3011,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
|
||||
fn report_unknown_field<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
variant: &ty::VariantDef<'tcx>,
|
||||
variant: ty::VariantDef<'tcx>,
|
||||
field: &ast::Field,
|
||||
skip_fields: &[ast::Field]) {
|
||||
fcx.type_error_message(
|
||||
|
@ -3095,7 +3095,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
fn check_struct_constructor<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
|
||||
id: ast::NodeId,
|
||||
span: codemap::Span,
|
||||
struct_def: &'tcx ty::ADTDef<'tcx>,
|
||||
struct_def: ty::AdtDef<'tcx>,
|
||||
fields: &'tcx [ast::Field],
|
||||
base_expr: Option<&'tcx ast::Expr>) {
|
||||
let tcx = fcx.ccx.tcx;
|
||||
|
|
|
@ -620,7 +620,7 @@ fn convert_field<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
struct_generics: &ty::Generics<'tcx>,
|
||||
struct_predicates: &ty::GenericPredicates<'tcx>,
|
||||
v: &ast::StructField,
|
||||
ty_f: &'tcx ty::FieldDef_<'tcx, 'tcx>)
|
||||
ty_f: ty::FieldDefMaster<'tcx>)
|
||||
{
|
||||
let tt = ccx.icx(struct_predicates).to_ty(&ExplicitRscope, &*v.node.ty);
|
||||
ty_f.fulfill_ty(tt);
|
||||
|
@ -748,7 +748,7 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
|
|||
let (scheme, predicates) = convert_typed_item(ccx, it);
|
||||
write_ty_to_tcx(tcx, it.id, scheme.ty);
|
||||
convert_enum_variant_types(ccx,
|
||||
tcx.lookup_adt_def(local_def(it.id)),
|
||||
tcx.lookup_adt_def_master(local_def(it.id)),
|
||||
scheme,
|
||||
predicates,
|
||||
&enum_definition.variants);
|
||||
|
@ -996,7 +996,7 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
|
|||
let (scheme, predicates) = convert_typed_item(ccx, it);
|
||||
write_ty_to_tcx(tcx, it.id, scheme.ty);
|
||||
|
||||
let variant = tcx.lookup_adt_def(local_def(it.id)).struct_variant();
|
||||
let variant = tcx.lookup_adt_def_master(local_def(it.id)).struct_variant();
|
||||
|
||||
for (f, ty_f) in struct_def.fields.iter().zip(variant.fields.iter()) {
|
||||
convert_field(ccx, &scheme.generics, &predicates, f, ty_f)
|
||||
|
@ -1023,7 +1023,7 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
|
|||
|
||||
fn convert_variant_ctor<'a, 'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
ctor_id: ast::NodeId,
|
||||
variant: &'tcx ty::VariantDef<'tcx>,
|
||||
variant: ty::VariantDef<'tcx>,
|
||||
scheme: ty::TypeScheme<'tcx>,
|
||||
predicates: ty::GenericPredicates<'tcx>) {
|
||||
let ctor_ty = match variant.kind() {
|
||||
|
@ -1049,7 +1049,7 @@ fn convert_variant_ctor<'a, 'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
}
|
||||
|
||||
fn convert_enum_variant_types<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
def: &'tcx ty::ADTDef_<'tcx, 'tcx>,
|
||||
def: ty::AdtDefMaster<'tcx>,
|
||||
scheme: ty::TypeScheme<'tcx>,
|
||||
predicates: ty::GenericPredicates<'tcx>,
|
||||
variants: &[P<ast::Variant>]) {
|
||||
|
@ -1090,7 +1090,7 @@ fn convert_struct_variant<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
did: ast::DefId,
|
||||
name: ast::Name,
|
||||
disr_val: ty::Disr,
|
||||
def: &ast::StructDef) -> ty::VariantDef_<'tcx, 'tcx> {
|
||||
def: &ast::StructDef) -> ty::VariantDefData<'tcx, 'tcx> {
|
||||
let mut seen_fields: FnvHashMap<ast::Name, Span> = FnvHashMap();
|
||||
let fields = def.fields.iter().map(|f| {
|
||||
let fid = local_def(f.node.id);
|
||||
|
@ -1106,14 +1106,14 @@ fn convert_struct_variant<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
seen_fields.insert(ident.name, f.span);
|
||||
}
|
||||
|
||||
ty::FieldDef_::new(fid, ident.name, vis)
|
||||
ty::FieldDefData::new(fid, ident.name, vis)
|
||||
},
|
||||
ast::UnnamedField(vis) => {
|
||||
ty::FieldDef_::new(fid, special_idents::unnamed_field.name, vis)
|
||||
ty::FieldDefData::new(fid, special_idents::unnamed_field.name, vis)
|
||||
}
|
||||
}
|
||||
}).collect();
|
||||
ty::VariantDef_ {
|
||||
ty::VariantDefData {
|
||||
did: did,
|
||||
name: name,
|
||||
disr_val: disr_val,
|
||||
|
@ -1124,13 +1124,13 @@ fn convert_struct_variant<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
fn convert_struct_def<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
it: &ast::Item,
|
||||
def: &ast::StructDef)
|
||||
-> &'tcx ty::ADTDef_<'tcx, 'tcx>
|
||||
-> ty::AdtDefMaster<'tcx>
|
||||
{
|
||||
|
||||
let did = local_def(it.id);
|
||||
tcx.intern_adt_def(
|
||||
did,
|
||||
ty::ADTKind::Struct,
|
||||
ty::AdtKind::Struct,
|
||||
vec![convert_struct_variant(tcx, did, it.ident.name, 0, def)]
|
||||
)
|
||||
}
|
||||
|
@ -1138,7 +1138,7 @@ fn convert_struct_def<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
fn convert_enum_def<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
it: &ast::Item,
|
||||
def: &ast::EnumDef)
|
||||
-> &'tcx ty::ADTDef_<'tcx, 'tcx>
|
||||
-> ty::AdtDefMaster<'tcx>
|
||||
{
|
||||
fn evaluate_disr_expr<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
repr_ty: Ty<'tcx>,
|
||||
|
@ -1202,18 +1202,18 @@ fn convert_enum_def<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
fn convert_enum_variant<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
v: &ast::Variant,
|
||||
disr: ty::Disr)
|
||||
-> ty::VariantDef_<'tcx, 'tcx>
|
||||
-> ty::VariantDefData<'tcx, 'tcx>
|
||||
{
|
||||
let did = local_def(v.node.id);
|
||||
let name = v.node.name.name;
|
||||
match v.node.kind {
|
||||
ast::TupleVariantKind(ref va) => {
|
||||
ty::VariantDef_ {
|
||||
ty::VariantDefData {
|
||||
did: did,
|
||||
name: name,
|
||||
disr_val: disr,
|
||||
fields: va.iter().map(|&ast::VariantArg { id, .. }| {
|
||||
ty::FieldDef_::new(
|
||||
ty::FieldDefData::new(
|
||||
local_def(id),
|
||||
special_idents::unnamed_field.name,
|
||||
ast::Visibility::Public
|
||||
|
@ -1240,7 +1240,7 @@ fn convert_enum_def<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
prev_disr = Some(disr);
|
||||
v
|
||||
}).collect();
|
||||
tcx.intern_adt_def(local_def(it.id), ty::ADTKind::Enum, variants)
|
||||
tcx.intern_adt_def(local_def(it.id), ty::AdtKind::Enum, variants)
|
||||
}
|
||||
|
||||
/// Ensures that the super-predicates of the trait with def-id
|
||||
|
|
|
@ -1730,7 +1730,7 @@ impl Clean<Item> for ast::StructField {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Clean<Item> for ty::FieldDef<'tcx> {
|
||||
impl<'tcx> Clean<Item> for ty::FieldDefData<'tcx, 'static> {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
use syntax::parse::token::special_idents::unnamed_field;
|
||||
use rustc::metadata::csearch;
|
||||
|
@ -1856,7 +1856,7 @@ impl Clean<Item> for doctree::Variant {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Clean<Item> for ty::VariantDef<'tcx> {
|
||||
impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
// use syntax::parse::token::special_idents::unnamed_field;
|
||||
let kind = match self.kind() {
|
||||
|
|
Loading…
Add table
Reference in a new issue