@@ -34,13 +34,12 @@ lazilly and on demand, and include logic that checks for cycles.
34
34
Demand is driven by calls to `AstConv::get_item_type_scheme` or
35
35
`AstConv::lookup_trait_def`.
36
36
37
- Currently, we "convert" types and traits in three phases (note that
37
+ Currently, we "convert" types and traits in two phases (note that
38
38
conversion only affects the types of items / enum variants / methods;
39
39
it does not e.g. compute the types of individual expressions):
40
40
41
41
0. Intrinsics
42
- 1. Trait definitions
43
- 2. Type definitions
42
+ 1. Trait/Type definitions
44
43
45
44
Conversion itself is done by simply walking each of the items in turn
46
45
and invoking an appropriate function (e.g., `trait_def_of_item` or
@@ -56,11 +55,6 @@ There are some shortcomings in this design:
56
55
- Because the type scheme includes defaults, cycles through type
57
56
parameter defaults are illegal even if those defaults are never
58
57
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
64
58
65
59
*/
66
60
@@ -105,9 +99,6 @@ use rustc_front::print::pprust;
105
99
pub fn collect_item_types ( tcx : & ty:: ctxt ) {
106
100
let ccx = & CrateCtxt { tcx : tcx, stack : RefCell :: new ( Vec :: new ( ) ) } ;
107
101
108
- let mut visitor = CollectTraitDefVisitor { ccx : ccx } ;
109
- ccx. tcx . map . krate ( ) . visit_all_items ( & mut visitor) ;
110
-
111
102
let mut visitor = CollectItemTypesVisitor { ccx : ccx } ;
112
103
ccx. tcx . map . krate ( ) . visit_all_items ( & mut visitor) ;
113
104
}
@@ -147,28 +138,6 @@ enum AstConvRequest {
147
138
}
148
139
149
140
///////////////////////////////////////////////////////////////////////////
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.
172
141
173
142
struct CollectItemTypesVisitor < ' a , ' tcx : ' a > {
174
143
ccx : & ' a CrateCtxt < ' a , ' tcx >
@@ -1286,16 +1255,11 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
1286
1255
substs : substs,
1287
1256
} ;
1288
1257
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) ;
1299
1263
1300
1264
return tcx. intern_trait_def ( trait_def) ;
1301
1265
0 commit comments