Skip to content

Commit 5940109

Browse files
committed
Merge lower_trait_item and lower_impl_item into check_item_type
1 parent cb158c2 commit 5940109

File tree

3 files changed

+26
-51
lines changed

3 files changed

+26
-51
lines changed

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,32 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
976976
// depends on typecheck and would therefore hide
977977
// any further errors in case one typeck fails.
978978
}
979+
DefKind::AssocFn => {
980+
tcx.ensure_ok().codegen_fn_attrs(def_id);
981+
tcx.ensure_ok().type_of(def_id);
982+
tcx.ensure_ok().fn_sig(def_id);
983+
tcx.ensure_ok().predicates_of(def_id);
984+
}
985+
DefKind::AssocConst => {
986+
tcx.ensure_ok().type_of(def_id);
987+
tcx.ensure_ok().predicates_of(def_id);
988+
}
989+
DefKind::AssocTy => {
990+
tcx.ensure_ok().predicates_of(def_id);
991+
992+
let assoc_item = tcx.associated_item(def_id);
993+
let has_type = match assoc_item.container {
994+
ty::AssocItemContainer::Impl => true,
995+
ty::AssocItemContainer::Trait => {
996+
tcx.ensure_ok().item_bounds(def_id);
997+
tcx.ensure_ok().item_self_bounds(def_id);
998+
assoc_item.defaultness(tcx).has_value()
999+
}
1000+
};
1001+
if has_type {
1002+
tcx.ensure_ok().type_of(def_id);
1003+
}
1004+
}
9791005
_ => {}
9801006
}
9811007
res

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,6 @@ fn check_trait_item<'tcx>(
328328
) -> Result<(), ErrorGuaranteed> {
329329
let def_id = trait_item.owner_id.def_id;
330330

331-
crate::collect::lower_trait_item(tcx, trait_item.trait_item_id());
332-
333331
let (method_sig, span) = match trait_item.kind {
334332
hir::TraitItemKind::Fn(ref sig, _) => (Some(sig), trait_item.span),
335333
hir::TraitItemKind::Type(_bounds, Some(ty)) => (None, ty.span),
@@ -831,8 +829,6 @@ fn check_impl_item<'tcx>(
831829
tcx: TyCtxt<'tcx>,
832830
impl_item: &'tcx hir::ImplItem<'tcx>,
833831
) -> Result<(), ErrorGuaranteed> {
834-
crate::collect::lower_impl_item(tcx, impl_item.impl_item_id());
835-
836832
let (method_sig, span) = match impl_item.kind {
837833
hir::ImplItemKind::Fn(ref sig, _) => (Some(sig), impl_item.span),
838834
// Constrain binding and overflow error spans to `<Ty>` in `type foo = <Ty>`.

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -615,53 +615,6 @@ fn get_new_lifetime_name<'tcx>(
615615
(1..).flat_map(a_to_z_repeat_n).find(|lt| !existing_lifetimes.contains(lt.as_str())).unwrap()
616616
}
617617

618-
pub(crate) fn lower_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) {
619-
let trait_item = tcx.hir_trait_item(trait_item_id);
620-
let def_id = trait_item_id.owner_id;
621-
tcx.ensure_ok().generics_of(def_id);
622-
623-
match trait_item.kind {
624-
hir::TraitItemKind::Fn(..) => {
625-
tcx.ensure_ok().codegen_fn_attrs(def_id);
626-
tcx.ensure_ok().type_of(def_id);
627-
tcx.ensure_ok().fn_sig(def_id);
628-
}
629-
630-
hir::TraitItemKind::Const(..) => {
631-
tcx.ensure_ok().type_of(def_id);
632-
}
633-
634-
hir::TraitItemKind::Type(_, Some(_)) => {
635-
tcx.ensure_ok().item_bounds(def_id);
636-
tcx.ensure_ok().item_self_bounds(def_id);
637-
tcx.ensure_ok().type_of(def_id);
638-
}
639-
640-
hir::TraitItemKind::Type(_, None) => {
641-
tcx.ensure_ok().item_bounds(def_id);
642-
tcx.ensure_ok().item_self_bounds(def_id);
643-
}
644-
};
645-
646-
tcx.ensure_ok().predicates_of(def_id);
647-
}
648-
649-
pub(super) fn lower_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::ImplItemId) {
650-
let def_id = impl_item_id.owner_id;
651-
tcx.ensure_ok().generics_of(def_id);
652-
tcx.ensure_ok().type_of(def_id);
653-
tcx.ensure_ok().predicates_of(def_id);
654-
let impl_item = tcx.hir_impl_item(impl_item_id);
655-
match impl_item.kind {
656-
hir::ImplItemKind::Fn(..) => {
657-
tcx.ensure_ok().codegen_fn_attrs(def_id);
658-
tcx.ensure_ok().fn_sig(def_id);
659-
}
660-
hir::ImplItemKind::Type(_) => {}
661-
hir::ImplItemKind::Const(..) => {}
662-
}
663-
}
664-
665618
pub(super) fn lower_variant_ctor(tcx: TyCtxt<'_>, def_id: LocalDefId) {
666619
tcx.ensure_ok().generics_of(def_id);
667620
tcx.ensure_ok().type_of(def_id);

0 commit comments

Comments
 (0)