diff options
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/check.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/wfcheck.rs | 16 | 
2 files changed, 11 insertions, 11 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 7732809a41d..5285d48ab3e 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -37,7 +37,8 @@ use {rustc_attr_data_structures as attrs, rustc_hir as hir}; use super::compare_impl_item::check_type_bounds; use super::*; use crate::check::wfcheck::{ - check_trait_item, check_variances_for_type_defn, check_where_clauses, enter_wf_checking_ctxt, + check_associated_item, check_trait_item, check_variances_for_type_defn, check_where_clauses, + enter_wf_checking_ctxt, }; fn add_abi_diag_help<T: EmissionGuarantee>(abi: ExternAbi, diag: &mut Diag<'_, T>) { @@ -981,6 +982,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), tcx.ensure_ok().type_of(def_id); tcx.ensure_ok().fn_sig(def_id); tcx.ensure_ok().predicates_of(def_id); + res = res.and(check_associated_item(tcx, def_id)); let assoc_item = tcx.associated_item(def_id); match assoc_item.container { ty::AssocItemContainer::Impl => {} @@ -992,6 +994,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), DefKind::AssocConst => { tcx.ensure_ok().type_of(def_id); tcx.ensure_ok().predicates_of(def_id); + res = res.and(check_associated_item(tcx, def_id)); let assoc_item = tcx.associated_item(def_id); match assoc_item.container { ty::AssocItemContainer::Impl => {} @@ -1002,6 +1005,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), } DefKind::AssocTy => { tcx.ensure_ok().predicates_of(def_id); + res = res.and(check_associated_item(tcx, def_id)); let assoc_item = tcx.associated_item(def_id); let has_type = match assoc_item.container { diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 597566f6158..5eb49822596 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -196,7 +196,7 @@ fn check_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), ErrorGua hir::Node::Crate(_) => bug!("check_well_formed cannot be applied to the crate root"), hir::Node::Item(item) => check_item(tcx, item), hir::Node::TraitItem(..) => Ok(()), - hir::Node::ImplItem(item) => check_impl_item(tcx, item), + hir::Node::ImplItem(..) => Ok(()), hir::Node::ForeignItem(item) => check_foreign_item(tcx, item), hir::Node::ConstBlock(_) | hir::Node::Expr(_) | hir::Node::OpaqueTy(_) => Ok(()), _ => unreachable!("{node:?}"), @@ -329,7 +329,7 @@ pub(crate) fn check_trait_item<'tcx>( // Check that an item definition in a subtrait is shadowing a supertrait item. lint_item_shadowing_supertrait_item(tcx, def_id); - let mut res = check_associated_item(tcx, def_id); + let mut res = Ok(()); if matches!(tcx.def_kind(def_id), DefKind::AssocFn) { for &assoc_ty_def_id in tcx.associated_types_for_impl_traits_in_associated_fn(def_id) { @@ -812,13 +812,6 @@ fn lint_item_shadowing_supertrait_item<'tcx>(tcx: TyCtxt<'tcx>, trait_item_def_i } } -fn check_impl_item<'tcx>( - tcx: TyCtxt<'tcx>, - impl_item: &'tcx hir::ImplItem<'tcx>, -) -> Result<(), ErrorGuaranteed> { - check_associated_item(tcx, impl_item.owner_id.def_id) -} - fn check_param_wf(tcx: TyCtxt<'_>, param: &ty::GenericParamDef) -> Result<(), ErrorGuaranteed> { match param.kind { // We currently only check wf of const params here. @@ -945,7 +938,10 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &ty::GenericParamDef) -> Result<(), Er } #[instrument(level = "debug", skip(tcx))] -fn check_associated_item(tcx: TyCtxt<'_>, item_id: LocalDefId) -> Result<(), ErrorGuaranteed> { +pub(crate) fn check_associated_item( + tcx: TyCtxt<'_>, + item_id: LocalDefId, +) -> Result<(), ErrorGuaranteed> { let loc = Some(WellFormedLoc::Ty(item_id)); enter_wf_checking_ctxt(tcx, item_id, |wfcx| { let item = tcx.associated_item(item_id);  | 
