提交 75c4f395 编写于 作者: N Niko Matsakis

Strip the trait-def phase from collect, which has no function.

上级 005fa143
......@@ -34,13 +34,12 @@
Demand is driven by calls to `AstConv::get_item_type_scheme` or
`AstConv::lookup_trait_def`.
Currently, we "convert" types and traits in three phases (note that
Currently, we "convert" types and traits in two phases (note that
conversion only affects the types of items / enum variants / methods;
it does not e.g. compute the types of individual expressions):
0. Intrinsics
1. Trait definitions
2. Type definitions
1. Trait/Type definitions
Conversion itself is done by simply walking each of the items in turn
and invoking an appropriate function (e.g., `trait_def_of_item` or
......@@ -56,11 +55,6 @@
- Because the type scheme includes defaults, cycles through type
parameter defaults are illegal even if those defaults are never
employed. This is not necessarily a bug.
- The phasing of trait definitions before type definitions does not
seem to be necessary, sufficient, or particularly helpful, given that
processing a trait definition can trigger processing a type def and
vice versa. However, if I remove it, I get ICEs, so some more work is
needed in that area. -nmatsakis
*/
......@@ -105,9 +99,6 @@
pub fn collect_item_types(tcx: &ty::ctxt) {
let ccx = &CrateCtxt { tcx: tcx, stack: RefCell::new(Vec::new()) };
let mut visitor = CollectTraitDefVisitor{ ccx: ccx };
ccx.tcx.map.krate().visit_all_items(&mut visitor);
let mut visitor = CollectItemTypesVisitor{ ccx: ccx };
ccx.tcx.map.krate().visit_all_items(&mut visitor);
}
......@@ -147,28 +138,6 @@ enum AstConvRequest {
}
///////////////////////////////////////////////////////////////////////////
// First phase: just collect *trait definitions* -- basically, the set
// of type parameters and supertraits. This is information we need to
// know later when parsing field defs.
struct CollectTraitDefVisitor<'a, 'tcx: 'a> {
ccx: &'a CrateCtxt<'a, 'tcx>
}
impl<'a, 'tcx, 'v> intravisit::Visitor<'v> for CollectTraitDefVisitor<'a, 'tcx> {
fn visit_item(&mut self, i: &hir::Item) {
match i.node {
hir::ItemTrait(..) => {
// computing the trait def also fills in the table
let _ = trait_def_of_item(self.ccx, i);
}
_ => { }
}
}
}
///////////////////////////////////////////////////////////////////////////
// Second phase: collection proper.
struct CollectItemTypesVisitor<'a, 'tcx: 'a> {
ccx: &'a CrateCtxt<'a, 'tcx>
......@@ -1286,16 +1255,11 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
substs: substs,
};
let trait_def = ty::TraitDef {
paren_sugar: paren_sugar,
unsafety: unsafety,
generics: ty_generics,
trait_ref: trait_ref,
associated_type_names: associated_type_names,
nonblanket_impls: RefCell::new(FnvHashMap()),
blanket_impls: RefCell::new(vec![]),
flags: Cell::new(ty::TraitFlags::NO_TRAIT_FLAGS)
};
let trait_def = ty::TraitDef::new(unsafety,
paren_sugar,
ty_generics,
trait_ref,
associated_type_names);
return tcx.intern_trait_def(trait_def);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册