Skip to content

Commit 422dd3b

Browse files
committed
use hir_module_items instead of visit_all_item_likes in check_mod_impl_wf query
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
1 parent f47f39b commit 422dd3b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

compiler/rustc_typeck/src/impl_wf_check.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use min_specialization::check_min_specialization;
1414
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1515
use rustc_errors::struct_span_err;
1616
use rustc_hir as hir;
17+
use rustc_hir::def::DefKind;
1718
use rustc_hir::def_id::LocalDefId;
1819
use rustc_hir::itemlikevisit::ItemLikeVisitor;
1920
use rustc_middle::ty::query::Providers;
@@ -63,8 +64,19 @@ pub fn impl_wf_check(tcx: TyCtxt<'_>) {
6364

6465
fn check_mod_impl_wf(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
6566
let min_specialization = tcx.features().min_specialization;
66-
tcx.hir()
67-
.visit_item_likes_in_module(module_def_id, &mut ImplWfCheck { tcx, min_specialization });
67+
let module = tcx.hir_module_items(module_def_id);
68+
for id in module.items() {
69+
if matches!(tcx.hir().def_kind(id.def_id), DefKind::Impl) {
70+
let item = tcx.hir().item(id);
71+
if let hir::ItemKind::Impl(ref impl_) = item.kind {
72+
enforce_impl_params_are_constrained(tcx, item.def_id, impl_.items);
73+
enforce_impl_items_are_distinct(tcx, impl_.items);
74+
if min_specialization {
75+
check_min_specialization(tcx, item.def_id.to_def_id(), item.span);
76+
}
77+
}
78+
}
79+
}
6880
}
6981

7082
pub fn provide(providers: &mut Providers) {

0 commit comments

Comments
 (0)