use middle::ty::{ImplContainer, ImplOrTraitItemId, MethodTraitItemId};
use middle::ty::{lookup_item_type};
use middle::ty::{t, ty_bool, ty_char, ty_bot, ty_box, ty_enum, ty_err};
-use middle::ty::{ty_str, ty_vec, ty_float, ty_infer, ty_int, ty_nil};
+use middle::ty::{ty_str, ty_vec, ty_float, ty_infer, ty_int, ty_nil, ty_open};
use middle::ty::{ty_param, Polytype, ty_ptr};
use middle::ty::{ty_rptr, ty_struct, ty_trait, ty_tup};
use middle::ty::{ty_uint, ty_unboxed_closure, ty_uniq, ty_bare_fn};
ty_nil | ty_bot | ty_bool | ty_char | ty_int(..) | ty_uint(..) | ty_float(..) |
ty_str(..) | ty_vec(..) | ty_bare_fn(..) | ty_closure(..) | ty_tup(..) |
- ty_infer(..) | ty_param(..) | ty_err |
+ ty_infer(..) | ty_param(..) | ty_err | ty_open(..) |
ty_box(_) | ty_uniq(_) | ty_ptr(_) | ty_rptr(_, _) => {
debug!("(getting base type) no base type; found {:?}",
get(original_type).sty);
ty_unboxed_closure(def_id, _) => {
Some(def_id)
}
- ty_rptr(_, ty::mt {ty, ..}) | ty_uniq(ty) => match ty::get(ty).sty {
- ty_trait(box ty::TyTrait { def_id, .. }) => {
- Some(def_id)
- }
- _ => {
- fail!("get_base_type() returned a type that wasn't an \
- enum, struct, or trait");
+ ty_ptr(ty::mt {ty, ..}) |
+ ty_rptr(_, ty::mt {ty, ..}) |
+ ty_uniq(ty) => {
+ match ty::get(ty).sty {
+ ty_trait(box ty::TyTrait { def_id, .. }) => {
+ Some(def_id)
+ }
+ _ => {
+ fail!("get_base_type() returned a type that wasn't an \
+ enum, struct, or trait");
+ }
}
- },
+ }
+ ty_trait(box ty::TyTrait { def_id, .. }) => {
+ Some(def_id)
+ }
_ => {
fail!("get_base_type() returned a type that wasn't an \
enum, struct, or trait");
}
}
-struct CoherenceChecker<'a> {
- crate_context: &'a CrateCtxt<'a>,
- inference_context: InferCtxt<'a>,
+struct CoherenceChecker<'a, 'tcx: 'a> {
+ crate_context: &'a CrateCtxt<'a, 'tcx>,
+ inference_context: InferCtxt<'a, 'tcx>,
}
-struct CoherenceCheckVisitor<'a> {
- cc: &'a CoherenceChecker<'a>
+struct CoherenceCheckVisitor<'a, 'tcx: 'a> {
+ cc: &'a CoherenceChecker<'a, 'tcx>
}
-impl<'a> visit::Visitor<()> for CoherenceCheckVisitor<'a> {
- fn visit_item(&mut self, item: &Item, _: ()) {
+impl<'a, 'tcx, 'v> visit::Visitor<'v> for CoherenceCheckVisitor<'a, 'tcx> {
+ fn visit_item(&mut self, item: &Item) {
//debug!("(checking coherence) item '{}'", token::get_ident(item.ident));
}
};
- visit::walk_item(self, item, ());
+ visit::walk_item(self, item);
}
}
-struct PrivilegedScopeVisitor<'a> { cc: &'a CoherenceChecker<'a> }
+struct PrivilegedScopeVisitor<'a, 'tcx: 'a> {
+ cc: &'a CoherenceChecker<'a, 'tcx>
+}
-impl<'a> visit::Visitor<()> for PrivilegedScopeVisitor<'a> {
- fn visit_item(&mut self, item: &Item, _: ()) {
+impl<'a, 'tcx, 'v> visit::Visitor<'v> for PrivilegedScopeVisitor<'a, 'tcx> {
+ fn visit_item(&mut self, item: &Item) {
match item.node {
ItemMod(ref module_) => {
// Then visit the module items.
- visit::walk_mod(self, module_, ());
+ visit::walk_mod(self, module_);
}
ItemImpl(_, None, ref ast_ty, _) => {
if !self.cc.ast_type_is_defined_in_local_crate(&**ast_ty) {
}
}
- visit::walk_item(self, item, ());
+ visit::walk_item(self, item);
}
_ => {
- visit::walk_item(self, item, ());
+ visit::walk_item(self, item);
}
}
}
}
-impl<'a> CoherenceChecker<'a> {
+impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
fn check(&self, krate: &Crate) {
// Check implementations and traits. This populates the tables
// containing the inherent methods and extension methods. It also
// builds up the trait inheritance table.
let mut visitor = CoherenceCheckVisitor { cc: self };
- visit::walk_crate(&mut visitor, krate, ());
+ visit::walk_crate(&mut visitor, krate);
// Check that there are no overlapping trait instances
self.check_implementation_coherence();
// Privileged scope checking
fn check_privileged_scopes(&self, krate: &Crate) {
let mut visitor = PrivilegedScopeVisitor{ cc: self };
- visit::walk_crate(&mut visitor, krate, ());
+ visit::walk_crate(&mut visitor, krate);
}
fn trait_ref_to_trait_def_id(&self, trait_ref: &TraitRef) -> DefId {
ast_items.iter()
.map(|ast_item| {
match *ast_item {
- ast::MethodImplItem(ast_method) => {
+ ast::MethodImplItem(ref ast_method) => {
MethodTraitItemId(
local_def(ast_method.id))
}
)
}
-pub fn check_coherence(crate_context: &CrateCtxt, krate: &Crate) {
+pub fn check_coherence(crate_context: &CrateCtxt) {
CoherenceChecker {
crate_context: crate_context,
inference_context: new_infer_ctxt(crate_context.tcx),
- }.check(krate);
+ }.check(crate_context.tcx.map.krate());
}