[] IsNoBuiltins(CrateNum),
[] ImplDefaultness(DefId),
[] CheckItemWellFormed(DefId),
+ [] CheckTraitItemWellFormed(DefId),
[] ReachableNonGenerics(CrateNum),
[] NativeLibraries(CrateNum),
[] PluginRegistrarFn(CrateNum),
[] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
[] fn check_item_well_formed: CheckItemWellFormed(DefId) -> (),
+ [] fn check_trait_item_well_formed: CheckTraitItemWellFormed(DefId) -> (),
// The DefIds of all non-generic functions and statics in the given crate
// that can be reached from outside the crate.
DepKind::IsNoBuiltins => { force!(is_no_builtins, krate!()); }
DepKind::ImplDefaultness => { force!(impl_defaultness, def_id!()); }
DepKind::CheckItemWellFormed => { force!(check_item_well_formed, def_id!()); }
+ DepKind::CheckTraitItemWellFormed => { force!(check_trait_item_well_formed, def_id!()); }
DepKind::ReachableNonGenerics => { force!(reachable_non_generics, krate!()); }
DepKind::NativeLibraries => { force!(native_libraries, krate!()); }
DepKind::PluginRegistrarFn => { force!(plugin_registrar_fn, krate!()); }
wfcheck::CheckTypeWellFormed::new(tcx).check_item_well_formed(def_id);
}
+fn check_trait_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
+ wfcheck::CheckTypeWellFormed::new(tcx).check_trait_item(def_id);
+}
+
pub fn provide(providers: &mut Providers) {
*providers = Providers {
typeck_item_bodies,
adt_destructor,
used_trait_imports,
check_item_well_formed,
+ check_trait_item_well_formed,
..*providers
};
}
}
}
+ pub fn check_trait_item(&mut self, def_id: DefId) {
+ let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap();
+ let trait_item = self.tcx.hir.expect_trait_item(node_id);
+
+ let method_sig = match trait_item.node {
+ hir::TraitItemKind::Method(ref sig, _) => Some(sig),
+ _ => None
+ };
+ CheckTypeWellFormed::new(self.tcx)
+ .check_associated_item(trait_item.id, trait_item.span, method_sig);
+ }
+
fn check_associated_item(&mut self,
item_id: ast::NodeId,
span: Span,
fn visit_trait_item(&mut self, trait_item: &'v hir::TraitItem) {
debug!("visit_trait_item: {:?}", trait_item);
- let method_sig = match trait_item.node {
- hir::TraitItemKind::Method(ref sig, _) => Some(sig),
- _ => None
- };
- CheckTypeWellFormed::new(self.tcx)
- .check_associated_item(trait_item.id, trait_item.span, method_sig);
+ let def_id = self.tcx.hir.local_def_id(trait_item.id);
+ ty::maps::queries::check_trait_item_well_formed::ensure(self.tcx, def_id);
intravisit::walk_trait_item(self, trait_item)
}