Skip to content

Commit ed71ba4

Browse files
committed
Remove trait collection phase, which is not needed.
1 parent 894152f commit ed71ba4

File tree

1 file changed

+2
-33
lines changed

1 file changed

+2
-33
lines changed

src/librustc_typeck/collect.rs

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ lazilly and on demand, and include logic that checks for cycles.
3434
Demand 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
3838
conversion only affects the types of items / enum variants / methods;
3939
it does not e.g. compute the types of individual expressions):
4040
4141
0. Intrinsics
42-
1. Trait definitions
43-
2. Type definitions
42+
1. Trait/Type definitions
4443
4544
Conversion itself is done by simply walking each of the items in turn
4645
and 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

@@ -107,9 +101,6 @@ use rustc_front::print::pprust;
107101
pub fn collect_item_types(tcx: &ty::ctxt) {
108102
let ccx = &CrateCtxt { tcx: tcx, stack: RefCell::new(Vec::new()) };
109103

110-
let mut visitor = CollectTraitDefVisitor{ ccx: ccx };
111-
ccx.tcx.map.krate().visit_all_items(&mut visitor);
112-
113104
let mut visitor = CollectItemTypesVisitor{ ccx: ccx };
114105
ccx.tcx.map.krate().visit_all_items(&mut visitor);
115106
}
@@ -149,28 +140,6 @@ enum AstConvRequest {
149140
}
150141

151142
///////////////////////////////////////////////////////////////////////////
152-
// First phase: just collect *trait definitions* -- basically, the set
153-
// of type parameters and supertraits. This is information we need to
154-
// know later when parsing field defs.
155-
156-
struct CollectTraitDefVisitor<'a, 'tcx: 'a> {
157-
ccx: &'a CrateCtxt<'a, 'tcx>
158-
}
159-
160-
impl<'a, 'tcx, 'v> intravisit::Visitor<'v> for CollectTraitDefVisitor<'a, 'tcx> {
161-
fn visit_item(&mut self, i: &hir::Item) {
162-
match i.node {
163-
hir::ItemTrait(..) => {
164-
// computing the trait def also fills in the table
165-
let _ = trait_def_of_item(self.ccx, i);
166-
}
167-
_ => { }
168-
}
169-
}
170-
}
171-
172-
///////////////////////////////////////////////////////////////////////////
173-
// Second phase: collection proper.
174143

175144
struct CollectItemTypesVisitor<'a, 'tcx: 'a> {
176145
ccx: &'a CrateCtxt<'a, 'tcx>

0 commit comments

Comments
 (0)