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)
|
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 cstore = &tcx.sess.cstore;
|
||||||
let cdata = cstore.get_crate_data(def.krate);
|
let cdata = cstore.get_crate_data(def.krate);
|
||||||
decoder::get_adt_def(&cstore.intr, &*cdata, def.node, tcx)
|
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,
|
pub fn get_adt_def<'tcx>(intr: &IdentInterner,
|
||||||
cdata: Cmd,
|
cdata: Cmd,
|
||||||
item_id: ast::NodeId,
|
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,
|
fn get_enum_variants<'tcx>(intr: &IdentInterner,
|
||||||
cdata: Cmd,
|
cdata: Cmd,
|
||||||
doc: rbml::Doc,
|
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;
|
let mut disr_val = 0;
|
||||||
reader::tagged_docs(doc, tag_items_data_item_variant).map(|p| {
|
reader::tagged_docs(doc, tag_items_data_item_variant).map(|p| {
|
||||||
let did = translated_def_id(cdata, p);
|
let did = translated_def_id(cdata, p);
|
||||||
|
@ -410,7 +410,7 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
|
||||||
let disr = disr_val;
|
let disr = disr_val;
|
||||||
disr_val = disr_val.wrapping_add(1);
|
disr_val = disr_val.wrapping_add(1);
|
||||||
|
|
||||||
ty::VariantDef_ {
|
ty::VariantDefData {
|
||||||
did: did,
|
did: did,
|
||||||
name: item_name(intr, item),
|
name: item_name(intr, item),
|
||||||
fields: get_variant_fields(intr, cdata, item, tcx),
|
fields: get_variant_fields(intr, cdata, item, tcx),
|
||||||
|
@ -421,19 +421,19 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
|
||||||
fn get_variant_fields<'tcx>(intr: &IdentInterner,
|
fn get_variant_fields<'tcx>(intr: &IdentInterner,
|
||||||
cdata: Cmd,
|
cdata: Cmd,
|
||||||
doc: rbml::Doc,
|
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| {
|
reader::tagged_docs(doc, tag_item_field).map(|f| {
|
||||||
let ff = item_family(f);
|
let ff = item_family(f);
|
||||||
match ff {
|
match ff {
|
||||||
PublicField | InheritedField => {},
|
PublicField | InheritedField => {},
|
||||||
_ => tcx.sess.bug(&format!("expected field, found {:?}", ff))
|
_ => tcx.sess.bug(&format!("expected field, found {:?}", ff))
|
||||||
};
|
};
|
||||||
ty::FieldDef_::new(item_def_id(f, cdata),
|
ty::FieldDefData::new(item_def_id(f, cdata),
|
||||||
item_name(intr, f),
|
item_name(intr, f),
|
||||||
struct_field_family_to_visibility(ff))
|
struct_field_family_to_visibility(ff))
|
||||||
}).chain(reader::tagged_docs(doc, tag_item_unnamed_field).map(|f| {
|
}).chain(reader::tagged_docs(doc, tag_item_unnamed_field).map(|f| {
|
||||||
let ff = item_family(f);
|
let ff = item_family(f);
|
||||||
ty::FieldDef_::new(item_def_id(f, cdata),
|
ty::FieldDefData::new(item_def_id(f, cdata),
|
||||||
special_idents::unnamed_field.name,
|
special_idents::unnamed_field.name,
|
||||||
struct_field_family_to_visibility(ff))
|
struct_field_family_to_visibility(ff))
|
||||||
})).collect()
|
})).collect()
|
||||||
|
@ -442,8 +442,8 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
|
||||||
cdata: Cmd,
|
cdata: Cmd,
|
||||||
doc: rbml::Doc,
|
doc: rbml::Doc,
|
||||||
did: ast::DefId,
|
did: ast::DefId,
|
||||||
tcx: &ty::ctxt<'tcx>) -> ty::VariantDef_<'tcx, 'tcx> {
|
tcx: &ty::ctxt<'tcx>) -> ty::VariantDefData<'tcx, 'tcx> {
|
||||||
ty::VariantDef_ {
|
ty::VariantDefData {
|
||||||
did: did,
|
did: did,
|
||||||
name: item_name(intr, doc),
|
name: item_name(intr, doc),
|
||||||
fields: get_variant_fields(intr, cdata, doc, tcx),
|
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 doc = lookup_item(item_id, cdata.data());
|
||||||
let did = ast::DefId { krate: cdata.cnum, node: item_id };
|
let did = ast::DefId { krate: cdata.cnum, node: item_id };
|
||||||
let (kind, variants) = match item_family(doc) {
|
let (kind, variants) = match item_family(doc) {
|
||||||
Enum => (ty::ADTKind::Enum,
|
Enum => (ty::AdtKind::Enum,
|
||||||
get_enum_variants(intr, cdata, doc, tcx)),
|
get_enum_variants(intr, cdata, doc, tcx)),
|
||||||
Struct => (ty::ADTKind::Struct,
|
Struct => (ty::AdtKind::Struct,
|
||||||
vec![get_struct_variant(intr, cdata, doc, did, tcx)]),
|
vec![get_struct_variant(intr, cdata, doc, did, tcx)]),
|
||||||
_ => tcx.sess.bug("get_adt_def called on a non-ADT")
|
_ => 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
|
// to support recursive structures
|
||||||
for variant in &adt.variants {
|
for variant in &adt.variants {
|
||||||
if variant.kind() == ty::VariantKind::Tuple &&
|
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
|
// tuple-like enum variant fields aren't real items - get the types
|
||||||
// from the ctor.
|
// from the ctor.
|
||||||
debug!("evaluating the ctor-type of {:?}",
|
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,
|
fn encode_struct_fields(rbml_w: &mut Encoder,
|
||||||
fields: &[ty::FieldDef],
|
variant: ty::VariantDef,
|
||||||
origin: DefId) {
|
origin: DefId) {
|
||||||
for f in fields {
|
for f in &variant.fields {
|
||||||
if f.name == special_idents::unnamed_field.name {
|
if f.name == special_idents::unnamed_field.name {
|
||||||
rbml_w.start_tag(tag_item_unnamed_field);
|
rbml_w.start_tag(tag_item_unnamed_field);
|
||||||
} else {
|
} else {
|
||||||
|
@ -315,14 +315,11 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
|
||||||
encode_stability(rbml_w, stab);
|
encode_stability(rbml_w, stab);
|
||||||
|
|
||||||
if let ty::VariantKind::Dict = variant.kind() {
|
if let ty::VariantKind::Dict = variant.kind() {
|
||||||
let idx = encode_info_for_struct(ecx,
|
let idx = encode_info_for_struct(ecx, rbml_w, variant, index);
|
||||||
rbml_w,
|
|
||||||
&variant.fields,
|
|
||||||
index);
|
|
||||||
encode_index(rbml_w, idx, write_i64);
|
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;
|
let specified_disr_val = variant.disr_val;
|
||||||
if specified_disr_val != 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 */
|
/* Returns an index of items in this class */
|
||||||
fn encode_info_for_struct<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
|
fn encode_info_for_struct<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
|
||||||
rbml_w: &mut Encoder,
|
rbml_w: &mut Encoder,
|
||||||
fields: &[ty::FieldDef<'tcx>],
|
variant: ty::VariantDef<'tcx>,
|
||||||
global_index: &mut Vec<entry<i64>>)
|
global_index: &mut Vec<entry<i64>>)
|
||||||
-> Vec<entry<i64>> {
|
-> Vec<entry<i64>> {
|
||||||
/* Each class has its own index, since different classes
|
/* 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();
|
let mut index = Vec::new();
|
||||||
/* We encode both private and public fields -- need to include
|
/* We encode both private and public fields -- need to include
|
||||||
private fields to get the offsets right */
|
private fields to get the offsets right */
|
||||||
for field in fields {
|
for field in &variant.fields {
|
||||||
let nm = field.name;
|
let nm = field.name;
|
||||||
let id = field.did.node;
|
let id = field.did.node;
|
||||||
|
|
||||||
|
@ -1153,13 +1150,13 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||||
}
|
}
|
||||||
ast::ItemStruct(ref struct_def, _) => {
|
ast::ItemStruct(ref struct_def, _) => {
|
||||||
let def = ecx.tcx.lookup_adt_def(def_id);
|
let def = ecx.tcx.lookup_adt_def(def_id);
|
||||||
let fields = &def.struct_variant().fields;
|
let variant = def.struct_variant();
|
||||||
|
|
||||||
/* First, encode the fields
|
/* First, encode the fields
|
||||||
These come first because we need to write them to make
|
These come first because we need to write them to make
|
||||||
the index, and the index needs to be in the item for the
|
the index, and the index needs to be in the item for the
|
||||||
class itself */
|
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*/
|
/* Index the class*/
|
||||||
add_to_index(item, rbml_w, index);
|
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
|
/* Encode def_ids for each field and method
|
||||||
for methods, write all the stuff get_trait_method
|
for methods, write all the stuff get_trait_method
|
||||||
needs to know*/
|
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));
|
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> {
|
impl<'tcx, 'container> ty::AdtDefData<'tcx, 'container> {
|
||||||
fn variant_of_ctor(&'tcx self, ctor: &Constructor) -> &'tcx VariantDef<'tcx> {
|
fn variant_of_ctor(&self,
|
||||||
|
ctor: &Constructor)
|
||||||
|
-> &VariantDefData<'tcx, 'container> {
|
||||||
match ctor {
|
match ctor {
|
||||||
&Variant(vid) => self.variant_with_id(vid),
|
&Variant(vid) => self.variant_with_id(vid),
|
||||||
_ => self.struct_variant()
|
_ => self.struct_variant()
|
||||||
|
|
|
@ -723,7 +723,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
||||||
// are properly handled.
|
// are properly handled.
|
||||||
self.walk_expr(with_expr);
|
self.walk_expr(with_expr);
|
||||||
|
|
||||||
fn contains_field_named(field: &ty::FieldDef,
|
fn contains_field_named(field: ty::FieldDef,
|
||||||
fields: &Vec<ast::Field>)
|
fields: &Vec<ast::Field>)
|
||||||
-> bool
|
-> bool
|
||||||
{
|
{
|
||||||
|
|
|
@ -278,8 +278,8 @@ fn fundamental_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
ty::TyBox(..) | ty::TyRef(..) =>
|
ty::TyBox(..) | ty::TyRef(..) =>
|
||||||
true,
|
true,
|
||||||
ty::TyEnum(def, _) | ty::TyStruct(def, _) => def.is_fundamental()
|
ty::TyEnum(def, _) | ty::TyStruct(def, _) =>
|
||||||
,
|
def.is_fundamental(),
|
||||||
ty::TyTrait(ref data) =>
|
ty::TyTrait(ref data) =>
|
||||||
tcx.has_attr(data.principal_def_id(), "fundamental"),
|
tcx.has_attr(data.principal_def_id(), "fundamental"),
|
||||||
_ =>
|
_ =>
|
||||||
|
|
|
@ -638,7 +638,7 @@ pub struct CtxtArenas<'tcx> {
|
||||||
|
|
||||||
// references
|
// references
|
||||||
trait_defs: TypedArena<TraitDef<'tcx>>,
|
trait_defs: TypedArena<TraitDef<'tcx>>,
|
||||||
adt_defs: TypedArena<ADTDef_<'tcx, 'tcx>>,
|
adt_defs: TypedArena<AdtDefData<'tcx, 'tcx>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> CtxtArenas<'tcx> {
|
impl<'tcx> CtxtArenas<'tcx> {
|
||||||
|
@ -766,7 +766,7 @@ pub struct ctxt<'tcx> {
|
||||||
|
|
||||||
pub impl_trait_refs: RefCell<DefIdMap<Option<TraitRef<'tcx>>>>,
|
pub impl_trait_refs: RefCell<DefIdMap<Option<TraitRef<'tcx>>>>,
|
||||||
pub trait_defs: RefCell<DefIdMap<&'tcx TraitDef<'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
|
/// Maps from the def-id of an item (trait/struct/enum/fn) to its
|
||||||
/// associated predicates.
|
/// associated predicates.
|
||||||
|
@ -937,10 +937,10 @@ impl<'tcx> ctxt<'tcx> {
|
||||||
|
|
||||||
pub fn intern_adt_def(&self,
|
pub fn intern_adt_def(&self,
|
||||||
did: DefId,
|
did: DefId,
|
||||||
kind: ADTKind,
|
kind: AdtKind,
|
||||||
variants: Vec<VariantDef_<'tcx, 'tcx>>)
|
variants: Vec<VariantDefData<'tcx, 'tcx>>)
|
||||||
-> &'tcx ADTDef_<'tcx, 'tcx> {
|
-> AdtDefMaster<'tcx> {
|
||||||
let def = ADTDef_::new(self, did, kind, variants);
|
let def = AdtDefData::new(self, did, kind, variants);
|
||||||
let interned = self.arenas.adt_defs.alloc(def);
|
let interned = self.arenas.adt_defs.alloc(def);
|
||||||
// this will need a transmute when reverse-variance is removed
|
// this will need a transmute when reverse-variance is removed
|
||||||
self.adt_defs.borrow_mut().insert(did, interned);
|
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
|
/// 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
|
/// the `ast_ty_to_ty_cache`. This is probably true for `TyStruct` as
|
||||||
/// well.
|
/// well.
|
||||||
TyEnum(&'tcx ADTDef<'tcx>, &'tcx Substs<'tcx>),
|
TyEnum(AdtDef<'tcx>, &'tcx Substs<'tcx>),
|
||||||
|
|
||||||
/// A structure type, defined with `struct`.
|
/// A structure type, defined with `struct`.
|
||||||
///
|
///
|
||||||
/// See warning about substitutions for enumerated types.
|
/// 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
|
/// `Box<T>`; this is nominally a struct in the documentation, but is
|
||||||
/// special-cased internally. For example, it is possible to implicitly
|
/// special-cased internally. For example, it is possible to implicitly
|
||||||
|
@ -3177,7 +3177,7 @@ impl<'tcx> TraitDef<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
flags ADTFlags: u32 {
|
flags AdtFlags: u32 {
|
||||||
const NO_ADT_FLAGS = 0,
|
const NO_ADT_FLAGS = 0,
|
||||||
const IS_ENUM = 1 << 0,
|
const IS_ENUM = 1 << 0,
|
||||||
const IS_DTORCK = 1 << 1, // is this a dtorck type?
|
const IS_DTORCK = 1 << 1, // is this a dtorck type?
|
||||||
|
@ -3188,18 +3188,23 @@ bitflags! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ADTDef<'tcx> = ADTDef_<'tcx, 'static>;
|
pub type AdtDef<'tcx> = &'tcx AdtDefData<'tcx, 'static>;
|
||||||
pub type VariantDef<'tcx> = VariantDef_<'tcx, 'static>;
|
pub type VariantDef<'tcx> = &'tcx VariantDefData<'tcx, 'static>;
|
||||||
pub type FieldDef<'tcx> = FieldDef_<'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 did: DefId,
|
||||||
pub name: Name, // struct's name if this is a struct
|
pub name: Name, // struct's name if this is a struct
|
||||||
pub disr_val: Disr,
|
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
|
/// The field's DefId. NOTE: the fields of tuple-like enum variants
|
||||||
/// are not real items, and don't have entries in tcache etc.
|
/// are not real items, and don't have entries in tcache etc.
|
||||||
pub did: DefId,
|
pub did: DefId,
|
||||||
|
@ -3208,7 +3213,7 @@ pub struct FieldDef_<'tcx, 'container: 'tcx> {
|
||||||
pub name: Name,
|
pub name: Name,
|
||||||
pub vis: ast::Visibility,
|
pub vis: ast::Visibility,
|
||||||
/// TyIVar is used here to allow for variance (see the doc at
|
/// TyIVar is used here to allow for variance (see the doc at
|
||||||
/// ADTDef_).
|
/// AdtDefData).
|
||||||
ty: TyIVar<'tcx, 'container>
|
ty: TyIVar<'tcx, 'container>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3221,60 +3226,60 @@ pub struct FieldDef_<'tcx, 'container: 'tcx> {
|
||||||
/// needs 2 lifetimes: the traditional variant lifetime ('tcx)
|
/// needs 2 lifetimes: the traditional variant lifetime ('tcx)
|
||||||
/// bounding the lifetime of the inner types is of course necessary.
|
/// bounding the lifetime of the inner types is of course necessary.
|
||||||
/// However, it is not sufficient - types from a child tcx must
|
/// 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
|
/// The 'container lifetime ensures that by outliving the container
|
||||||
/// tcx and preventing shorter-lived types from being inserted. When
|
/// tcx and preventing shorter-lived types from being inserted. When
|
||||||
/// write access is not needed, the 'container lifetime can be
|
/// write access is not needed, the 'container lifetime can be
|
||||||
/// erased to 'static, which can be done by the ADTDef wrapper.
|
/// erased to 'static, which can be done by the AdtDef wrapper.
|
||||||
pub struct ADTDef_<'tcx, 'container: 'tcx> {
|
pub struct AdtDefData<'tcx, 'container: 'tcx> {
|
||||||
pub did: DefId,
|
pub did: DefId,
|
||||||
pub variants: Vec<VariantDef_<'tcx, 'container>>,
|
pub variants: Vec<VariantDefData<'tcx, 'container>>,
|
||||||
flags: Cell<ADTFlags>,
|
flags: Cell<AdtFlags>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, 'container> PartialEq for ADTDef_<'tcx, 'container> {
|
impl<'tcx, 'container> PartialEq for AdtDefData<'tcx, 'container> {
|
||||||
// ADTDef are always interned and this is part of TyS equality
|
// AdtDefData are always interned and this is part of TyS equality
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, other: &Self) -> bool { self as *const _ == other as *const _ }
|
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]
|
#[inline]
|
||||||
fn hash<H: Hasher>(&self, s: &mut H) {
|
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)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub enum ADTKind { Struct, Enum }
|
pub enum AdtKind { Struct, Enum }
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub enum VariantKind { Dict, Tuple, Unit }
|
pub enum VariantKind { Dict, Tuple, Unit }
|
||||||
|
|
||||||
impl<'tcx, 'container> ADTDef_<'tcx, 'container> {
|
impl<'tcx, 'container> AdtDefData<'tcx, 'container> {
|
||||||
fn new(tcx: &ctxt<'tcx>,
|
fn new(tcx: &ctxt<'tcx>,
|
||||||
did: DefId,
|
did: DefId,
|
||||||
kind: ADTKind,
|
kind: AdtKind,
|
||||||
variants: Vec<VariantDef_<'tcx, 'container>>) -> Self {
|
variants: Vec<VariantDefData<'tcx, 'container>>) -> Self {
|
||||||
let mut flags = ADTFlags::NO_ADT_FLAGS;
|
let mut flags = AdtFlags::NO_ADT_FLAGS;
|
||||||
let attrs = tcx.get_attrs(did);
|
let attrs = tcx.get_attrs(did);
|
||||||
if attrs.iter().any(|item| item.check_name("fundamental")) {
|
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")) {
|
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() {
|
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 {
|
if let AdtKind::Enum = kind {
|
||||||
flags = flags | ADTFlags::IS_ENUM;
|
flags = flags | AdtFlags::IS_ENUM;
|
||||||
}
|
}
|
||||||
ADTDef {
|
AdtDefData {
|
||||||
did: did,
|
did: did,
|
||||||
variants: variants,
|
variants: variants,
|
||||||
flags: Cell::new(flags),
|
flags: Cell::new(flags),
|
||||||
|
@ -3283,18 +3288,18 @@ impl<'tcx, 'container> ADTDef_<'tcx, 'container> {
|
||||||
|
|
||||||
fn calculate_dtorck(&'tcx self, tcx: &ctxt<'tcx>) {
|
fn calculate_dtorck(&'tcx self, tcx: &ctxt<'tcx>) {
|
||||||
if tcx.is_adt_dtorck(self) {
|
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.
|
/// Returns the kind of the ADT - Struct or Enum.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn adt_kind(&self) -> ADTKind {
|
pub fn adt_kind(&self) -> AdtKind {
|
||||||
if self.flags.get().intersects(ADTFlags::IS_ENUM) {
|
if self.flags.get().intersects(AdtFlags::IS_ENUM) {
|
||||||
ADTKind::Enum
|
AdtKind::Enum
|
||||||
} else {
|
} else {
|
||||||
ADTKind::Struct
|
AdtKind::Struct
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3303,28 +3308,28 @@ impl<'tcx, 'container> ADTDef_<'tcx, 'container> {
|
||||||
/// alive; Otherwise, only the contents are required to be.
|
/// alive; Otherwise, only the contents are required to be.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_dtorck(&'tcx self, tcx: &ctxt<'tcx>) -> bool {
|
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.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
|
/// Returns whether this type is #[fundamental] for the purposes
|
||||||
/// of coherence checking.
|
/// of coherence checking.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_fundamental(&self) -> bool {
|
pub fn is_fundamental(&self) -> bool {
|
||||||
self.flags.get().intersects(ADTFlags::IS_FUNDAMENTAL)
|
self.flags.get().intersects(AdtFlags::IS_FUNDAMENTAL)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_simd(&self) -> bool {
|
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>.
|
/// Returns true if this is PhantomData<T>.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_phantom_data(&self) -> bool {
|
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.
|
/// 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
|
/// Asserts this is a struct and returns the struct's unique
|
||||||
/// variant.
|
/// variant.
|
||||||
pub fn struct_variant(&self) -> &ty::VariantDef_<'tcx, 'container> {
|
pub fn struct_variant(&self) -> &VariantDefData<'tcx, 'container> {
|
||||||
assert!(self.adt_kind() == ADTKind::Struct);
|
assert!(self.adt_kind() == AdtKind::Struct);
|
||||||
&self.variants[0]
|
&self.variants[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3354,12 +3359,12 @@ impl<'tcx, 'container> ADTDef_<'tcx, 'container> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn all_fields(&self) ->
|
pub fn all_fields(&self) ->
|
||||||
iter::FlatMap<
|
iter::FlatMap<
|
||||||
slice::Iter<VariantDef_<'tcx, 'container>>,
|
slice::Iter<VariantDefData<'tcx, 'container>>,
|
||||||
slice::Iter<FieldDef_<'tcx, 'container>>,
|
slice::Iter<FieldDefData<'tcx, 'container>>,
|
||||||
for<'s> fn(&'s VariantDef_<'tcx, 'container>)
|
for<'s> fn(&'s VariantDefData<'tcx, 'container>)
|
||||||
-> slice::Iter<'s, FieldDef_<'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]
|
#[inline]
|
||||||
|
@ -3377,14 +3382,14 @@ impl<'tcx, 'container> ADTDef_<'tcx, 'container> {
|
||||||
self.variants.iter().all(|v| v.fields.is_empty())
|
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
|
self.variants
|
||||||
.iter()
|
.iter()
|
||||||
.find(|v| v.did == vid)
|
.find(|v| v.did == vid)
|
||||||
.expect("variant_with_id: unknown variant")
|
.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 {
|
match def {
|
||||||
def::DefVariant(_, vid, _) => self.variant_with_id(vid),
|
def::DefVariant(_, vid, _) => self.variant_with_id(vid),
|
||||||
def::DefStruct(..) | def::DefTy(..) => self.struct_variant(),
|
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]
|
#[inline]
|
||||||
fn fields_iter(&self) -> slice::Iter<FieldDef_<'tcx, 'container>> {
|
fn fields_iter(&self) -> slice::Iter<FieldDefData<'tcx, 'container>> {
|
||||||
self.fields.iter()
|
self.fields.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kind(&self) -> VariantKind {
|
pub fn kind(&self) -> VariantKind {
|
||||||
match self.fields.get(0) {
|
match self.fields.get(0) {
|
||||||
None => VariantKind::Unit,
|
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
|
VariantKind::Tuple
|
||||||
}
|
}
|
||||||
Some(_) => VariantKind::Dict
|
Some(_) => VariantKind::Dict
|
||||||
|
@ -3414,21 +3419,23 @@ impl<'tcx, 'container> VariantDef_<'tcx, 'container> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[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)
|
self.fields.iter().find(|f| f.name == name)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[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()
|
self.find_field_named(name).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, 'container> FieldDef_<'tcx, 'container> {
|
impl<'tcx, 'container> FieldDefData<'tcx, 'container> {
|
||||||
pub fn new(did: DefId,
|
pub fn new(did: DefId,
|
||||||
name: Name,
|
name: Name,
|
||||||
vis: ast::Visibility) -> Self {
|
vis: ast::Visibility) -> Self {
|
||||||
FieldDef_ {
|
FieldDefData {
|
||||||
did: did,
|
did: did,
|
||||||
name: name,
|
name: name,
|
||||||
vis: vis,
|
vis: vis,
|
||||||
|
@ -3934,7 +3941,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||||
self.mk_imm_ref(self.mk_region(ty::ReStatic), self.mk_str())
|
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
|
// take a copy of substs so that we own the vectors inside
|
||||||
self.mk_ty(TyEnum(def, substs))
|
self.mk_ty(TyEnum(def, substs))
|
||||||
}
|
}
|
||||||
|
@ -4036,7 +4043,7 @@ impl<'tcx> ctxt<'tcx> {
|
||||||
self.mk_ty(TyProjection(inner))
|
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
|
// take a copy of substs so that we own the vectors inside
|
||||||
self.mk_ty(TyStruct(def, substs))
|
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 {
|
match self.sty {
|
||||||
TyStruct(adt, _) | TyEnum(adt, _) => Some(adt),
|
TyStruct(adt, _) | TyEnum(adt, _) => Some(adt),
|
||||||
_ => None
|
_ => None
|
||||||
|
@ -4677,7 +4684,7 @@ impl<'tcx> TyS<'tcx> {
|
||||||
|
|
||||||
// True if instantiating an instance of `r_ty` requires an instance of `r_ty`.
|
// True if instantiating an instance of `r_ty` requires an instance of `r_ty`.
|
||||||
pub fn is_instantiable(&'tcx self, cx: &ctxt<'tcx>) -> bool {
|
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 {
|
r_ty: Ty<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||||
debug!("type_requires({:?}, {:?})?",
|
debug!("type_requires({:?}, {:?})?",
|
||||||
r_ty, ty);
|
r_ty, ty);
|
||||||
|
@ -4689,7 +4696,7 @@ impl<'tcx> TyS<'tcx> {
|
||||||
return r;
|
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 {
|
r_ty: Ty<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||||
debug!("subtypes_require({:?}, {:?})?",
|
debug!("subtypes_require({:?}, {:?})?",
|
||||||
r_ty, ty);
|
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 {
|
match ty.sty {
|
||||||
TyStruct(ty_def, _) | TyEnum(ty_def, _) => {
|
TyStruct(ty_def, _) | TyEnum(ty_def, _) => {
|
||||||
ty_def == def
|
ty_def == def
|
||||||
|
@ -5969,14 +5976,23 @@ impl<'tcx> ctxt<'tcx> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given the did of a trait, returns its canonical trait ref.
|
/// Given the did of an ADT, return a master reference to its
|
||||||
pub fn lookup_adt_def(&self, did: ast::DefId) -> &'tcx ADTDef_<'tcx, 'tcx> {
|
/// 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(
|
lookup_locally_or_in_crate_store(
|
||||||
"adt_defs", did, &self.adt_defs,
|
"adt_defs", did, &self.adt_defs,
|
||||||
|| csearch::get_adt_def(self, did)
|
|| 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.
|
/// Given the did of an item, returns its full set of predicates.
|
||||||
pub fn lookup_predicates(&self, did: ast::DefId) -> GenericPredicates<'tcx> {
|
pub fn lookup_predicates(&self, did: ast::DefId) -> GenericPredicates<'tcx> {
|
||||||
lookup_locally_or_in_crate_store(
|
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
|
/// Returns true if this ADT is a dtorck type, i.e. whether it being
|
||||||
/// safe for destruction requires it to be alive
|
/// 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) {
|
let dtor_method = match self.destructor_for_type.borrow().get(&adt.did) {
|
||||||
Some(dtor) => *dtor,
|
Some(dtor) => *dtor,
|
||||||
None => return false
|
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 {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
ty::tls::with(|tcx| {
|
ty::tls::with(|tcx| {
|
||||||
write!(f, "{}", tcx.item_path_str(self.did))
|
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
|
/// 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
|
/// not `Sync`, but may be extended in the future to be usable as a true
|
||||||
/// concurrency type.
|
/// 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)]
|
#[derive(PartialEq)]
|
||||||
pub struct Ivar<T: Copy> {
|
pub struct Ivar<T: Copy> {
|
||||||
data: Cell<Option<T>>
|
data: Cell<Option<T>>
|
||||||
|
|
|
@ -413,7 +413,7 @@ enum FfiResult {
|
||||||
/// expanded to cover NonZero raw pointers and newtypes.
|
/// expanded to cover NonZero raw pointers and newtypes.
|
||||||
/// FIXME: This duplicates code in trans.
|
/// FIXME: This duplicates code in trans.
|
||||||
fn is_repr_nullable_ptr<'tcx>(tcx: &ty::ctxt<'tcx>,
|
fn is_repr_nullable_ptr<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||||
def: &ty::ADTDef<'tcx>,
|
def: ty::AdtDef<'tcx>,
|
||||||
substs: &Substs<'tcx>)
|
substs: &Substs<'tcx>)
|
||||||
-> bool {
|
-> bool {
|
||||||
if def.variants.len() == 2 {
|
if def.variants.len() == 2 {
|
||||||
|
|
|
@ -687,8 +687,8 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
||||||
// Checks that a field is in scope.
|
// Checks that a field is in scope.
|
||||||
fn check_field(&mut self,
|
fn check_field(&mut self,
|
||||||
span: Span,
|
span: Span,
|
||||||
def: &'tcx ty::ADTDef<'tcx>,
|
def: ty::AdtDef<'tcx>,
|
||||||
v: &'tcx ty::VariantDef<'tcx>,
|
v: ty::VariantDef<'tcx>,
|
||||||
name: FieldName) {
|
name: FieldName) {
|
||||||
let field = match name {
|
let field = match name {
|
||||||
NamedField(f_name) => {
|
NamedField(f_name) => {
|
||||||
|
@ -703,10 +703,10 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let struct_desc = match def.adt_kind() {
|
let struct_desc = match def.adt_kind() {
|
||||||
ty::ADTKind::Struct =>
|
ty::AdtKind::Struct =>
|
||||||
format!("struct `{}`", self.tcx.item_path_str(def.did)),
|
format!("struct `{}`", self.tcx.item_path_str(def.did)),
|
||||||
// struct variant fields have inherited visibility
|
// struct variant fields have inherited visibility
|
||||||
ty::ADTKind::Enum => return
|
ty::AdtKind::Enum => return
|
||||||
};
|
};
|
||||||
let msg = match name {
|
let msg = match name {
|
||||||
NamedField(name) => format!("field `{}` of {} is private",
|
NamedField(name) => format!("field `{}` of {} is private",
|
||||||
|
|
|
@ -742,7 +742,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
|
||||||
ex: &ast::Expr,
|
ex: &ast::Expr,
|
||||||
path: &ast::Path,
|
path: &ast::Path,
|
||||||
fields: &Vec<ast::Field>,
|
fields: &Vec<ast::Field>,
|
||||||
variant: &ty::VariantDef,
|
variant: ty::VariantDef,
|
||||||
base: &Option<P<ast::Expr>>) {
|
base: &Option<P<ast::Expr>>) {
|
||||||
if generated_code(path.span) {
|
if generated_code(path.span) {
|
||||||
return
|
return
|
||||||
|
|
|
@ -613,7 +613,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||||
|
|
||||||
pub fn get_field_ref_data(&self,
|
pub fn get_field_ref_data(&self,
|
||||||
field_ref: &ast::Field,
|
field_ref: &ast::Field,
|
||||||
variant: &ty::VariantDef,
|
variant: ty::VariantDef,
|
||||||
parent: NodeId)
|
parent: NodeId)
|
||||||
-> VariableRefData {
|
-> VariableRefData {
|
||||||
let f = variant.field_named(field_ref.ident.node.name);
|
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>,
|
fn get_cases<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||||
adt: &ty::ADTDef<'tcx>,
|
adt: ty::AdtDef<'tcx>,
|
||||||
substs: &subst::Substs<'tcx>)
|
substs: &subst::Substs<'tcx>)
|
||||||
-> Vec<Case<'tcx>> {
|
-> Vec<Case<'tcx>> {
|
||||||
adt.variants.iter().map(|vi| {
|
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>,
|
fn iter_variant<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
||||||
repr: &adt::Repr<'tcx>,
|
repr: &adt::Repr<'tcx>,
|
||||||
av: ValueRef,
|
av: ValueRef,
|
||||||
variant: &ty::VariantDef<'tcx>,
|
variant: ty::VariantDef<'tcx>,
|
||||||
substs: &Substs<'tcx>,
|
substs: &Substs<'tcx>,
|
||||||
f: &mut F)
|
f: &mut F)
|
||||||
-> Block<'blk, 'tcx> where
|
-> Block<'blk, 'tcx> where
|
||||||
|
|
|
@ -1242,7 +1242,7 @@ pub fn langcall(bcx: Block,
|
||||||
/// Return the VariantDef corresponding to an inlined variant node
|
/// Return the VariantDef corresponding to an inlined variant node
|
||||||
pub fn inlined_variant_def<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
pub fn inlined_variant_def<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||||
inlined_vid: ast::NodeId)
|
inlined_vid: ast::NodeId)
|
||||||
-> &'tcx ty::VariantDef<'tcx>
|
-> ty::VariantDef<'tcx>
|
||||||
{
|
{
|
||||||
|
|
||||||
let ctor_ty = ccx.tcx().node_id_to_type(inlined_vid);
|
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
|
// Creates MemberDescriptions for the fields of a struct
|
||||||
struct StructMemberDescriptionFactory<'tcx> {
|
struct StructMemberDescriptionFactory<'tcx> {
|
||||||
variant: &'tcx ty::VariantDef<'tcx>,
|
variant: ty::VariantDef<'tcx>,
|
||||||
substs: &'tcx subst::Substs<'tcx>,
|
substs: &'tcx subst::Substs<'tcx>,
|
||||||
is_simd: bool,
|
is_simd: bool,
|
||||||
span: Span,
|
span: Span,
|
||||||
|
@ -1489,7 +1489,7 @@ enum EnumDiscriminantInfo {
|
||||||
fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
enum_type: Ty<'tcx>,
|
enum_type: Ty<'tcx>,
|
||||||
struct_def: &adt::Struct<'tcx>,
|
struct_def: &adt::Struct<'tcx>,
|
||||||
variant: &ty::VariantDef<'tcx>,
|
variant: ty::VariantDef<'tcx>,
|
||||||
discriminant_info: EnumDiscriminantInfo,
|
discriminant_info: EnumDiscriminantInfo,
|
||||||
containing_scope: DIScope,
|
containing_scope: DIScope,
|
||||||
span: Span)
|
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
|
/// Returns the normalized type of a struct field
|
||||||
pub fn field_ty<'tcx>(tcx: &ty::ctxt<'tcx>,
|
pub fn field_ty<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||||
param_substs: &Substs<'tcx>,
|
param_substs: &Substs<'tcx>,
|
||||||
f: &ty::FieldDef<'tcx>)
|
f: ty::FieldDef<'tcx>)
|
||||||
-> Ty<'tcx>
|
-> Ty<'tcx>
|
||||||
{
|
{
|
||||||
normalize_associated_type(tcx, &f.ty(tcx, param_substs))
|
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>,
|
pub fn check_struct_pat_fields<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
fields: &'tcx [Spanned<ast::FieldPat>],
|
fields: &'tcx [Spanned<ast::FieldPat>],
|
||||||
variant: &ty::VariantDef<'tcx>,
|
variant: ty::VariantDef<'tcx>,
|
||||||
substs: &Substs<'tcx>,
|
substs: &Substs<'tcx>,
|
||||||
etc: bool) {
|
etc: bool) {
|
||||||
let tcx = pcx.fcx.ccx.tcx;
|
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 } => {
|
TypeContext::ADT { def_id, variant, field, field_index } => {
|
||||||
let adt = tcx.lookup_adt_def(def_id);
|
let adt = tcx.lookup_adt_def(def_id);
|
||||||
let variant_name = match adt.adt_kind() {
|
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),
|
tcx.item_path_str(def_id),
|
||||||
variant),
|
variant),
|
||||||
ty::ADTKind::Struct => format!("struct {}",
|
ty::AdtKind::Struct => format!("struct {}",
|
||||||
tcx.item_path_str(def_id))
|
tcx.item_path_str(def_id))
|
||||||
};
|
};
|
||||||
let field_name = if field == special_idents::unnamed_field.name {
|
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
|
// FIXME(arielb1): use this instead of field.ty everywhere
|
||||||
pub fn field_ty(&self,
|
pub fn field_ty(&self,
|
||||||
span: Span,
|
span: Span,
|
||||||
field: &ty::FieldDef<'tcx>,
|
field: ty::FieldDef<'tcx>,
|
||||||
substs: &Substs<'tcx>)
|
substs: &Substs<'tcx>)
|
||||||
-> Ty<'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
|
// 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,
|
field: &ast::SpannedIdent,
|
||||||
tcx: &ty::ctxt<'tcx>,
|
tcx: &ty::ctxt<'tcx>,
|
||||||
skip : Vec<InternedString>) {
|
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>,
|
fn report_unknown_field<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
variant: &ty::VariantDef<'tcx>,
|
variant: ty::VariantDef<'tcx>,
|
||||||
field: &ast::Field,
|
field: &ast::Field,
|
||||||
skip_fields: &[ast::Field]) {
|
skip_fields: &[ast::Field]) {
|
||||||
fcx.type_error_message(
|
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>,
|
fn check_struct_constructor<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
|
||||||
id: ast::NodeId,
|
id: ast::NodeId,
|
||||||
span: codemap::Span,
|
span: codemap::Span,
|
||||||
struct_def: &'tcx ty::ADTDef<'tcx>,
|
struct_def: ty::AdtDef<'tcx>,
|
||||||
fields: &'tcx [ast::Field],
|
fields: &'tcx [ast::Field],
|
||||||
base_expr: Option<&'tcx ast::Expr>) {
|
base_expr: Option<&'tcx ast::Expr>) {
|
||||||
let tcx = fcx.ccx.tcx;
|
let tcx = fcx.ccx.tcx;
|
||||||
|
|
|
@ -620,7 +620,7 @@ fn convert_field<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||||
struct_generics: &ty::Generics<'tcx>,
|
struct_generics: &ty::Generics<'tcx>,
|
||||||
struct_predicates: &ty::GenericPredicates<'tcx>,
|
struct_predicates: &ty::GenericPredicates<'tcx>,
|
||||||
v: &ast::StructField,
|
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);
|
let tt = ccx.icx(struct_predicates).to_ty(&ExplicitRscope, &*v.node.ty);
|
||||||
ty_f.fulfill_ty(tt);
|
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);
|
let (scheme, predicates) = convert_typed_item(ccx, it);
|
||||||
write_ty_to_tcx(tcx, it.id, scheme.ty);
|
write_ty_to_tcx(tcx, it.id, scheme.ty);
|
||||||
convert_enum_variant_types(ccx,
|
convert_enum_variant_types(ccx,
|
||||||
tcx.lookup_adt_def(local_def(it.id)),
|
tcx.lookup_adt_def_master(local_def(it.id)),
|
||||||
scheme,
|
scheme,
|
||||||
predicates,
|
predicates,
|
||||||
&enum_definition.variants);
|
&enum_definition.variants);
|
||||||
|
@ -996,7 +996,7 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
|
||||||
let (scheme, predicates) = convert_typed_item(ccx, it);
|
let (scheme, predicates) = convert_typed_item(ccx, it);
|
||||||
write_ty_to_tcx(tcx, it.id, scheme.ty);
|
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()) {
|
for (f, ty_f) in struct_def.fields.iter().zip(variant.fields.iter()) {
|
||||||
convert_field(ccx, &scheme.generics, &predicates, f, ty_f)
|
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>,
|
fn convert_variant_ctor<'a, 'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||||
ctor_id: ast::NodeId,
|
ctor_id: ast::NodeId,
|
||||||
variant: &'tcx ty::VariantDef<'tcx>,
|
variant: ty::VariantDef<'tcx>,
|
||||||
scheme: ty::TypeScheme<'tcx>,
|
scheme: ty::TypeScheme<'tcx>,
|
||||||
predicates: ty::GenericPredicates<'tcx>) {
|
predicates: ty::GenericPredicates<'tcx>) {
|
||||||
let ctor_ty = match variant.kind() {
|
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>,
|
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>,
|
scheme: ty::TypeScheme<'tcx>,
|
||||||
predicates: ty::GenericPredicates<'tcx>,
|
predicates: ty::GenericPredicates<'tcx>,
|
||||||
variants: &[P<ast::Variant>]) {
|
variants: &[P<ast::Variant>]) {
|
||||||
|
@ -1090,7 +1090,7 @@ fn convert_struct_variant<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||||
did: ast::DefId,
|
did: ast::DefId,
|
||||||
name: ast::Name,
|
name: ast::Name,
|
||||||
disr_val: ty::Disr,
|
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 mut seen_fields: FnvHashMap<ast::Name, Span> = FnvHashMap();
|
||||||
let fields = def.fields.iter().map(|f| {
|
let fields = def.fields.iter().map(|f| {
|
||||||
let fid = local_def(f.node.id);
|
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);
|
seen_fields.insert(ident.name, f.span);
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::FieldDef_::new(fid, ident.name, vis)
|
ty::FieldDefData::new(fid, ident.name, vis)
|
||||||
},
|
},
|
||||||
ast::UnnamedField(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();
|
}).collect();
|
||||||
ty::VariantDef_ {
|
ty::VariantDefData {
|
||||||
did: did,
|
did: did,
|
||||||
name: name,
|
name: name,
|
||||||
disr_val: disr_val,
|
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>,
|
fn convert_struct_def<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||||
it: &ast::Item,
|
it: &ast::Item,
|
||||||
def: &ast::StructDef)
|
def: &ast::StructDef)
|
||||||
-> &'tcx ty::ADTDef_<'tcx, 'tcx>
|
-> ty::AdtDefMaster<'tcx>
|
||||||
{
|
{
|
||||||
|
|
||||||
let did = local_def(it.id);
|
let did = local_def(it.id);
|
||||||
tcx.intern_adt_def(
|
tcx.intern_adt_def(
|
||||||
did,
|
did,
|
||||||
ty::ADTKind::Struct,
|
ty::AdtKind::Struct,
|
||||||
vec![convert_struct_variant(tcx, did, it.ident.name, 0, def)]
|
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>,
|
fn convert_enum_def<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||||
it: &ast::Item,
|
it: &ast::Item,
|
||||||
def: &ast::EnumDef)
|
def: &ast::EnumDef)
|
||||||
-> &'tcx ty::ADTDef_<'tcx, 'tcx>
|
-> ty::AdtDefMaster<'tcx>
|
||||||
{
|
{
|
||||||
fn evaluate_disr_expr<'tcx>(tcx: &ty::ctxt<'tcx>,
|
fn evaluate_disr_expr<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||||
repr_ty: Ty<'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>,
|
fn convert_enum_variant<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||||
v: &ast::Variant,
|
v: &ast::Variant,
|
||||||
disr: ty::Disr)
|
disr: ty::Disr)
|
||||||
-> ty::VariantDef_<'tcx, 'tcx>
|
-> ty::VariantDefData<'tcx, 'tcx>
|
||||||
{
|
{
|
||||||
let did = local_def(v.node.id);
|
let did = local_def(v.node.id);
|
||||||
let name = v.node.name.name;
|
let name = v.node.name.name;
|
||||||
match v.node.kind {
|
match v.node.kind {
|
||||||
ast::TupleVariantKind(ref va) => {
|
ast::TupleVariantKind(ref va) => {
|
||||||
ty::VariantDef_ {
|
ty::VariantDefData {
|
||||||
did: did,
|
did: did,
|
||||||
name: name,
|
name: name,
|
||||||
disr_val: disr,
|
disr_val: disr,
|
||||||
fields: va.iter().map(|&ast::VariantArg { id, .. }| {
|
fields: va.iter().map(|&ast::VariantArg { id, .. }| {
|
||||||
ty::FieldDef_::new(
|
ty::FieldDefData::new(
|
||||||
local_def(id),
|
local_def(id),
|
||||||
special_idents::unnamed_field.name,
|
special_idents::unnamed_field.name,
|
||||||
ast::Visibility::Public
|
ast::Visibility::Public
|
||||||
|
@ -1240,7 +1240,7 @@ fn convert_enum_def<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||||
prev_disr = Some(disr);
|
prev_disr = Some(disr);
|
||||||
v
|
v
|
||||||
}).collect();
|
}).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
|
/// 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 {
|
fn clean(&self, cx: &DocContext) -> Item {
|
||||||
use syntax::parse::token::special_idents::unnamed_field;
|
use syntax::parse::token::special_idents::unnamed_field;
|
||||||
use rustc::metadata::csearch;
|
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 {
|
fn clean(&self, cx: &DocContext) -> Item {
|
||||||
// use syntax::parse::token::special_idents::unnamed_field;
|
// use syntax::parse::token::special_idents::unnamed_field;
|
||||||
let kind = match self.kind() {
|
let kind = match self.kind() {
|
||||||
|
|
Loading…
Reference in a new issue