Skip to content

Commit c80c31a

Browse files
committedDec 2, 2016
Auto merge of #38053 - eddyb:lazy-9, r=nikomatsakis
[9/n] rustc: move type information out of AdtDef and TraitDef. _This is part of a series ([prev](#37688) | [next]()) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https://github.com/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well. If any motivation is unclear, please ask for additional PR description clarifications or code comments._ <hr> Both `AdtDef` and `TraitDef` contained type information (field types, generics and predicates) which was required to create them, preventing their use before that type information exists, or in the case of field types, *mutation* was required, leading to a variance-magicking implementation of `ivar`s. This PR takes that information out and the resulting cleaner setup could even eventually end up merged with HIR, because, just like `AssociatedItem` before it, there's no dependency on types anymore. (With one exception, variant discriminants should probably be moved into their own map later.)
·
1.88.01.15.0
2 parents 2f8fd53 + 07ff914 commit c80c31a

File tree

49 files changed

+322
-564
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+322
-564
lines changed
 

‎src/librustc/dep_graph/dep_node.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ pub enum DepNode<D: Clone + Debug> {
110110
// predicates for an item wind up in `ItemSignature`).
111111
AssociatedItems(D),
112112
ItemSignature(D),
113-
FieldTy(D),
114113
SizedConstraint(D),
115114
AssociatedItemDefIds(D),
116115
InherentImpls(D),
@@ -161,7 +160,6 @@ impl<D: Clone + Debug> DepNode<D> {
161160
TypeckItemBody,
162161
AssociatedItems,
163162
ItemSignature,
164-
FieldTy,
165163
AssociatedItemDefIds,
166164
InherentImpls,
167165
TraitImpls,
@@ -229,7 +227,6 @@ impl<D: Clone + Debug> DepNode<D> {
229227
TransInlinedItem(ref d) => op(d).map(TransInlinedItem),
230228
AssociatedItems(ref d) => op(d).map(AssociatedItems),
231229
ItemSignature(ref d) => op(d).map(ItemSignature),
232-
FieldTy(ref d) => op(d).map(FieldTy),
233230
SizedConstraint(ref d) => op(d).map(SizedConstraint),
234231
AssociatedItemDefIds(ref d) => op(d).map(AssociatedItemDefIds),
235232
InherentImpls(ref d) => op(d).map(InherentImpls),

‎src/librustc/middle/cstore.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ pub trait CrateStore<'tcx> {
278278
fn item_generics<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
279279
-> ty::Generics<'tcx>;
280280
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute>;
281-
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef<'tcx>;
282-
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>;
281+
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef;
282+
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> &'tcx ty::AdtDef;
283283
fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>;
284284
fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec<DefId>;
285285

@@ -425,9 +425,9 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
425425
fn item_generics<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
426426
-> ty::Generics<'tcx> { bug!("item_generics") }
427427
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute> { bug!("item_attrs") }
428-
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef<'tcx>
428+
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef
429429
{ bug!("trait_def") }
430-
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>
430+
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> &'tcx ty::AdtDef
431431
{ bug!("adt_def") }
432432
fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name> { bug!("fn_arg_names") }
433433
fn inherent_implementations_for_type(&self, def_id: DefId) -> Vec<DefId> { vec![] }

0 commit comments

Comments
 (0)
Please sign in to comment.