1
Fork 0

Queryify check_impl_item_well_formed

Fixes #46753
This commit is contained in:
Wesley Wiser 2018-03-10 17:17:30 -05:00
parent edbd02fd35
commit 4f1f389d06
5 changed files with 21 additions and 6 deletions

View file

@ -581,6 +581,7 @@ define_dep_nodes!( <'tcx>
[] ImplDefaultness(DefId), [] ImplDefaultness(DefId),
[] CheckItemWellFormed(DefId), [] CheckItemWellFormed(DefId),
[] CheckTraitItemWellFormed(DefId), [] CheckTraitItemWellFormed(DefId),
[] CheckImplItemWellFormed(DefId),
[] ReachableNonGenerics(CrateNum), [] ReachableNonGenerics(CrateNum),
[] NativeLibraries(CrateNum), [] NativeLibraries(CrateNum),
[] PluginRegistrarFn(CrateNum), [] PluginRegistrarFn(CrateNum),

View file

@ -300,6 +300,7 @@ define_maps! { <'tcx>
[] fn check_item_well_formed: CheckItemWellFormed(DefId) -> (), [] fn check_item_well_formed: CheckItemWellFormed(DefId) -> (),
[] fn check_trait_item_well_formed: CheckTraitItemWellFormed(DefId) -> (), [] fn check_trait_item_well_formed: CheckTraitItemWellFormed(DefId) -> (),
[] fn check_impl_item_well_formed: CheckImplItemWellFormed(DefId) -> (),
// The DefIds of all non-generic functions and statics in the given crate // The DefIds of all non-generic functions and statics in the given crate
// that can be reached from outside the crate. // that can be reached from outside the crate.

View file

@ -873,6 +873,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
DepKind::ImplDefaultness => { force!(impl_defaultness, def_id!()); } DepKind::ImplDefaultness => { force!(impl_defaultness, def_id!()); }
DepKind::CheckItemWellFormed => { force!(check_item_well_formed, def_id!()); } DepKind::CheckItemWellFormed => { force!(check_item_well_formed, def_id!()); }
DepKind::CheckTraitItemWellFormed => { force!(check_trait_item_well_formed, def_id!()); } DepKind::CheckTraitItemWellFormed => { force!(check_trait_item_well_formed, def_id!()); }
DepKind::CheckImplItemWellFormed => { force!(check_impl_item_well_formed, def_id!()); }
DepKind::ReachableNonGenerics => { force!(reachable_non_generics, krate!()); } DepKind::ReachableNonGenerics => { force!(reachable_non_generics, krate!()); }
DepKind::NativeLibraries => { force!(native_libraries, krate!()); } DepKind::NativeLibraries => { force!(native_libraries, krate!()); }
DepKind::PluginRegistrarFn => { force!(plugin_registrar_fn, krate!()); } DepKind::PluginRegistrarFn => { force!(plugin_registrar_fn, krate!()); }

View file

@ -726,6 +726,10 @@ fn check_trait_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: D
wfcheck::CheckTypeWellFormed::new(tcx).check_trait_item(def_id); wfcheck::CheckTypeWellFormed::new(tcx).check_trait_item(def_id);
} }
fn check_impl_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
wfcheck::CheckTypeWellFormed::new(tcx).check_impl_item(def_id);
}
pub fn provide(providers: &mut Providers) { pub fn provide(providers: &mut Providers) {
*providers = Providers { *providers = Providers {
typeck_item_bodies, typeck_item_bodies,
@ -735,6 +739,7 @@ pub fn provide(providers: &mut Providers) {
used_trait_imports, used_trait_imports,
check_item_well_formed, check_item_well_formed,
check_trait_item_well_formed, check_trait_item_well_formed,
check_impl_item_well_formed,
..*providers ..*providers
}; };
} }

View file

@ -171,6 +171,17 @@ impl<'a, 'gcx> CheckTypeWellFormed<'a, 'gcx> {
.check_associated_item(trait_item.id, trait_item.span, method_sig); .check_associated_item(trait_item.id, trait_item.span, method_sig);
} }
pub fn check_impl_item(&mut self, def_id: DefId) {
let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap();
let impl_item = self.tcx.hir.expect_impl_item(node_id);
let method_sig = match impl_item.node {
hir::ImplItemKind::Method(ref sig, _) => Some(sig),
_ => None
};
self.check_associated_item(impl_item.id, impl_item.span, method_sig);
}
fn check_associated_item(&mut self, fn check_associated_item(&mut self,
item_id: ast::NodeId, item_id: ast::NodeId,
span: Span, span: Span,
@ -694,12 +705,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'a, 'tcx> {
fn visit_impl_item(&mut self, impl_item: &'v hir::ImplItem) { fn visit_impl_item(&mut self, impl_item: &'v hir::ImplItem) {
debug!("visit_impl_item: {:?}", impl_item); debug!("visit_impl_item: {:?}", impl_item);
let method_sig = match impl_item.node { let def_id = self.tcx.hir.local_def_id(impl_item.id);
hir::ImplItemKind::Method(ref sig, _) => Some(sig), ty::maps::queries::check_impl_item_well_formed::ensure(self.tcx, def_id);
_ => None
};
CheckTypeWellFormed::new(self.tcx)
.check_associated_item(impl_item.id, impl_item.span, method_sig);
intravisit::walk_impl_item(self, impl_item) intravisit::walk_impl_item(self, impl_item)
} }
} }