diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-09-06 01:26:02 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-09-08 22:17:53 +0300 |
| commit | f2b672d5567c3b20542e845baaf8a9c47d9df907 (patch) | |
| tree | 60e8ffd531ac9debe6281bf81442ebe0dc181e07 /src/librustc_metadata/decoder.rs | |
| parent | c615b215331d2715cc2eed31b98f41393242f39d (diff) | |
| download | rust-f2b672d5567c3b20542e845baaf8a9c47d9df907.tar.gz rust-f2b672d5567c3b20542e845baaf8a9c47d9df907.zip | |
Refactor `TyStruct`/`TyEnum`/`TyUnion` into `TyAdt`
Diffstat (limited to 'src/librustc_metadata/decoder.rs')
| -rw-r--r-- | src/librustc_metadata/decoder.rs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 6b48b4dfabc..4dc06f0d024 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -36,7 +36,7 @@ use rustc::hir::def::Def; use rustc::hir::def_id::{DefId, DefIndex}; use middle::lang_items; use rustc::ty::{ImplContainer, TraitContainer}; -use rustc::ty::{self, Ty, TyCtxt, TypeFoldable, VariantKind}; +use rustc::ty::{self, AdtKind, Ty, TyCtxt, TypeFoldable, VariantKind}; use rustc_const_math::ConstInt; @@ -453,23 +453,19 @@ pub fn get_adt_def<'a, 'tcx>(cdata: Cmd, let mut ctor_did = None; let (kind, variants) = match item_family(doc) { Enum => { - (ty::AdtKind::Enum, - get_enum_variants(cdata, doc)) + (AdtKind::Enum, get_enum_variants(cdata, doc)) } Struct(..) => { // Use separate constructor id for unit/tuple structs and reuse did for braced structs. ctor_did = reader::maybe_get_doc(doc, tag_items_data_item_struct_ctor).map(|ctor_doc| { translated_def_id(cdata, ctor_doc) }); - (ty::AdtKind::Struct, - vec![get_struct_variant(cdata, doc, ctor_did.unwrap_or(did))]) + (AdtKind::Struct, vec![get_struct_variant(cdata, doc, ctor_did.unwrap_or(did))]) } Union => { - (ty::AdtKind::Union, - vec![get_struct_variant(cdata, doc, did)]) + (AdtKind::Union, vec![get_struct_variant(cdata, doc, did)]) } - _ => bug!("get_adt_def called on a non-ADT {:?} - {:?}", - item_family(doc), did) + _ => bug!("get_adt_def called on a non-ADT {:?} - {:?}", item_family(doc), did) }; let adt = tcx.intern_adt_def(did, kind, variants); @@ -481,8 +477,7 @@ pub fn get_adt_def<'a, 'tcx>(cdata: Cmd, // this needs to be done *after* the variant is interned, // to support recursive structures for variant in &adt.variants { - if variant.kind == ty::VariantKind::Tuple && - adt.adt_kind() == ty::AdtKind::Enum { + if variant.kind == ty::VariantKind::Tuple && adt.is_enum() { // tuple-like enum variant fields aren't real items - get the types // from the ctor. debug!("evaluating the ctor-type of {:?}", |
