Skip to content

Commit 4f1f389

Browse files
committed
Queryify check_impl_item_well_formed
Fixes #46753
1 parent edbd02f commit 4f1f389

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ define_dep_nodes!( <'tcx>
581581
[] ImplDefaultness(DefId),
582582
[] CheckItemWellFormed(DefId),
583583
[] CheckTraitItemWellFormed(DefId),
584+
[] CheckImplItemWellFormed(DefId),
584585
[] ReachableNonGenerics(CrateNum),
585586
[] NativeLibraries(CrateNum),
586587
[] PluginRegistrarFn(CrateNum),

src/librustc/ty/maps/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ define_maps! { <'tcx>
300300

301301
[] fn check_item_well_formed: CheckItemWellFormed(DefId) -> (),
302302
[] fn check_trait_item_well_formed: CheckTraitItemWellFormed(DefId) -> (),
303+
[] fn check_impl_item_well_formed: CheckImplItemWellFormed(DefId) -> (),
303304

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

src/librustc/ty/maps/plumbing.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
873873
DepKind::ImplDefaultness => { force!(impl_defaultness, def_id!()); }
874874
DepKind::CheckItemWellFormed => { force!(check_item_well_formed, def_id!()); }
875875
DepKind::CheckTraitItemWellFormed => { force!(check_trait_item_well_formed, def_id!()); }
876+
DepKind::CheckImplItemWellFormed => { force!(check_impl_item_well_formed, def_id!()); }
876877
DepKind::ReachableNonGenerics => { force!(reachable_non_generics, krate!()); }
877878
DepKind::NativeLibraries => { force!(native_libraries, krate!()); }
878879
DepKind::PluginRegistrarFn => { force!(plugin_registrar_fn, krate!()); }

src/librustc_typeck/check/mod.rs

Lines changed: 5 additions & 0 deletions
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

Lines changed: 13 additions & 6 deletions
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)