Skip to content

Commit 2b3d2a5

Browse files
committed
Queryify check_impl_item_well_formed
Fixes #46753
1 parent 25baba1 commit 2b3d2a5

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

src/librustc/dep_graph/dep_node.rs

+1
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ define_dep_nodes!( <'tcx>
577577
[] ImplDefaultness(DefId),
578578
[] CheckItemWellFormed(DefId),
579579
[] CheckTraitItemWellFormed(DefId),
580+
[] CheckImplItemWellFormed(DefId),
580581
[] ReachableNonGenerics(CrateNum),
581582
[] NativeLibraries(CrateNum),
582583
[] PluginRegistrarFn(CrateNum),

src/librustc/ty/maps/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ define_maps! { <'tcx>
294294

295295
[] fn check_item_well_formed: CheckItemWellFormed(DefId) -> (),
296296
[] fn check_trait_item_well_formed: CheckTraitItemWellFormed(DefId) -> (),
297+
[] fn check_impl_item_well_formed: CheckImplItemWellFormed(DefId) -> (),
297298

298299
// The DefIds of all non-generic functions and statics in the given crate
299300
// that can be reached from outside the crate.

src/librustc/ty/maps/plumbing.rs

+1
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
871871
DepKind::ImplDefaultness => { force!(impl_defaultness, def_id!()); }
872872
DepKind::CheckItemWellFormed => { force!(check_item_well_formed, def_id!()); }
873873
DepKind::CheckTraitItemWellFormed => { force!(check_trait_item_well_formed, def_id!()); }
874+
DepKind::CheckImplItemWellFormed => { force!(check_impl_item_well_formed, def_id!()); }
874875
DepKind::ReachableNonGenerics => { force!(reachable_non_generics, krate!()); }
875876
DepKind::NativeLibraries => { force!(native_libraries, krate!()); }
876877
DepKind::PluginRegistrarFn => { force!(plugin_registrar_fn, krate!()); }

src/librustc_typeck/check/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,10 @@ fn check_trait_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: D
726726
wfcheck::CheckTypeWellFormed::new(tcx).check_trait_item(def_id);
727727
}
728728

729+
fn check_impl_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
730+
wfcheck::CheckTypeWellFormed::new(tcx).check_impl_item(def_id);
731+
}
732+
729733
pub fn provide(providers: &mut Providers) {
730734
*providers = Providers {
731735
typeck_item_bodies,
@@ -735,6 +739,7 @@ pub fn provide(providers: &mut Providers) {
735739
used_trait_imports,
736740
check_item_well_formed,
737741
check_trait_item_well_formed,
742+
check_impl_item_well_formed,
738743
..*providers
739744
};
740745
}

src/librustc_typeck/check/wfcheck.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,17 @@ impl<'a, 'gcx> CheckTypeWellFormed<'a, 'gcx> {
171171
.check_associated_item(trait_item.id, trait_item.span, method_sig);
172172
}
173173

174+
pub fn check_impl_item(&mut self, def_id: DefId) {
175+
let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap();
176+
let impl_item = self.tcx.hir.expect_impl_item(node_id);
177+
178+
let method_sig = match impl_item.node {
179+
hir::ImplItemKind::Method(ref sig, _) => Some(sig),
180+
_ => None
181+
};
182+
self.check_associated_item(impl_item.id, impl_item.span, method_sig);
183+
}
184+
174185
fn check_associated_item(&mut self,
175186
item_id: ast::NodeId,
176187
span: Span,
@@ -694,12 +705,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'a, 'tcx> {
694705

695706
fn visit_impl_item(&mut self, impl_item: &'v hir::ImplItem) {
696707
debug!("visit_impl_item: {:?}", impl_item);
697-
let method_sig = match impl_item.node {
698-
hir::ImplItemKind::Method(ref sig, _) => Some(sig),
699-
_ => None
700-
};
701-
CheckTypeWellFormed::new(self.tcx)
702-
.check_associated_item(impl_item.id, impl_item.span, method_sig);
708+
let def_id = self.tcx.hir.local_def_id(impl_item.id);
709+
ty::maps::queries::check_impl_item_well_formed::ensure(self.tcx, def_id);
703710
intravisit::walk_impl_item(self, impl_item)
704711
}
705712
}

0 commit comments

Comments
 (0)