@@ -34,13 +34,12 @@ lazilly and on demand, and include logic that checks for cycles.
3434Demand is driven by calls to `AstConv::get_item_type_scheme` or
3535`AstConv::lookup_trait_def`.
3636
37- Currently, we "convert" types and traits in three phases (note that
37+ Currently, we "convert" types and traits in two phases (note that
3838conversion only affects the types of items / enum variants / methods;
3939it does not e.g. compute the types of individual expressions):
4040
41410. Intrinsics
42- 1. Trait definitions
43- 2. Type definitions
42+ 1. Trait/Type definitions
4443
4544Conversion itself is done by simply walking each of the items in turn
4645and invoking an appropriate function (e.g., `trait_def_of_item` or
@@ -56,11 +55,6 @@ There are some shortcomings in this design:
5655- Because the type scheme includes defaults, cycles through type
5756 parameter defaults are illegal even if those defaults are never
5857 employed. This is not necessarily a bug.
59- - The phasing of trait definitions before type definitions does not
60- seem to be necessary, sufficient, or particularly helpful, given that
61- processing a trait definition can trigger processing a type def and
62- vice versa. However, if I remove it, I get ICEs, so some more work is
63- needed in that area. -nmatsakis
6458
6559*/
6660
@@ -105,9 +99,6 @@ use rustc_front::print::pprust;
10599pub fn collect_item_types ( tcx : & ty:: ctxt ) {
106100 let ccx = & CrateCtxt { tcx : tcx, stack : RefCell :: new ( Vec :: new ( ) ) } ;
107101
108- let mut visitor = CollectTraitDefVisitor { ccx : ccx } ;
109- ccx. tcx . map . krate ( ) . visit_all_items ( & mut visitor) ;
110-
111102 let mut visitor = CollectItemTypesVisitor { ccx : ccx } ;
112103 ccx. tcx . map . krate ( ) . visit_all_items ( & mut visitor) ;
113104}
@@ -147,28 +138,6 @@ enum AstConvRequest {
147138}
148139
149140///////////////////////////////////////////////////////////////////////////
150- // First phase: just collect *trait definitions* -- basically, the set
151- // of type parameters and supertraits. This is information we need to
152- // know later when parsing field defs.
153-
154- struct CollectTraitDefVisitor < ' a , ' tcx : ' a > {
155- ccx : & ' a CrateCtxt < ' a , ' tcx >
156- }
157-
158- impl < ' a , ' tcx , ' v > intravisit:: Visitor < ' v > for CollectTraitDefVisitor < ' a , ' tcx > {
159- fn visit_item ( & mut self , i : & hir:: Item ) {
160- match i. node {
161- hir:: ItemTrait ( ..) => {
162- // computing the trait def also fills in the table
163- let _ = trait_def_of_item ( self . ccx , i) ;
164- }
165- _ => { }
166- }
167- }
168- }
169-
170- ///////////////////////////////////////////////////////////////////////////
171- // Second phase: collection proper.
172141
173142struct CollectItemTypesVisitor < ' a , ' tcx : ' a > {
174143 ccx : & ' a CrateCtxt < ' a , ' tcx >
@@ -1286,16 +1255,11 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
12861255 substs : substs,
12871256 } ;
12881257
1289- let trait_def = ty:: TraitDef {
1290- paren_sugar : paren_sugar,
1291- unsafety : unsafety,
1292- generics : ty_generics,
1293- trait_ref : trait_ref,
1294- associated_type_names : associated_type_names,
1295- nonblanket_impls : RefCell :: new ( FnvHashMap ( ) ) ,
1296- blanket_impls : RefCell :: new ( vec ! [ ] ) ,
1297- flags : Cell :: new ( ty:: TraitFlags :: NO_TRAIT_FLAGS )
1298- } ;
1258+ let trait_def = ty:: TraitDef :: new ( unsafety,
1259+ paren_sugar,
1260+ ty_generics,
1261+ trait_ref,
1262+ associated_type_names) ;
12991263
13001264 return tcx. intern_trait_def ( trait_def) ;
13011265
0 commit comments