Skip to content

Commit f676a86

Browse files
committed
Merge lower_trait_item and lower_impl_item into check_item_type
1 parent a62acc9 commit f676a86

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),
@@ -827,8 +825,6 @@ fn check_impl_item<'tcx>(
827825
tcx: TyCtxt<'tcx>,
828826
impl_item: &'tcx hir::ImplItem<'tcx>,
829827
) -> Result<(), ErrorGuaranteed> {
830-
crate::collect::lower_impl_item(tcx, impl_item.impl_item_id());
831-
832828
let (method_sig, span) = match impl_item.kind {
833829
hir::ImplItemKind::Fn(ref sig, _) => (Some(sig), impl_item.span),
834830
// 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
@@ -614,53 +614,6 @@ fn get_new_lifetime_name<'tcx>(
614614
(1..).flat_map(a_to_z_repeat_n).find(|lt| !existing_lifetimes.contains(lt.as_str())).unwrap()
615615
}
616616

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

0 commit comments

Comments
 (0)