@@ -9,7 +9,7 @@ use rustc_errors::codes::*;
99use rustc_hir:: def:: { CtorKind , DefKind } ;
1010use rustc_hir:: { LangItem , Node , intravisit} ;
1111use rustc_infer:: infer:: { RegionVariableOrigin , TyCtxtInferExt } ;
12- use rustc_infer:: traits:: { Obligation , ObligationCauseCode } ;
12+ use rustc_infer:: traits:: { Obligation , ObligationCauseCode , WellFormedLoc } ;
1313use rustc_lint_defs:: builtin:: {
1414 REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS , UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS ,
1515} ;
@@ -34,7 +34,9 @@ use {rustc_attr_data_structures as attrs, rustc_hir as hir};
3434
3535use super :: compare_impl_item:: check_type_bounds;
3636use super :: * ;
37- use crate :: check:: wfcheck:: check_variances_for_type_defn;
37+ use crate :: check:: wfcheck:: {
38+ check_variances_for_type_defn, check_where_clauses, enter_wf_checking_ctxt,
39+ } ;
3840
3941pub fn check_abi ( tcx : TyCtxt < ' _ > , span : Span , abi : ExternAbi ) {
4042 if !tcx. sess . target . is_abi_supported ( abi) {
@@ -703,6 +705,7 @@ fn check_static_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) {
703705}
704706
705707pub ( crate ) fn check_item_type ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) -> Result < ( ) , ErrorGuaranteed > {
708+ let mut res = Ok ( ( ) ) ;
706709 match tcx. def_kind ( def_id) {
707710 DefKind :: Static { .. } => {
708711 check_static_inhabited ( tcx, def_id) ;
@@ -776,6 +779,18 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
776779 DefKind :: TyAlias => {
777780 check_type_alias_type_params_are_used ( tcx, def_id) ;
778781 if tcx. type_alias_is_lazy ( def_id) {
782+ res = res. and ( enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
783+ let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
784+ let span = tcx. def_span ( def_id) ;
785+ let item_ty = wfcx. deeply_normalize ( span, Some ( WellFormedLoc :: Ty ( def_id) ) , ty) ;
786+ wfcx. register_wf_obligation (
787+ span,
788+ Some ( WellFormedLoc :: Ty ( def_id) ) ,
789+ item_ty. into ( ) ,
790+ ) ;
791+ check_where_clauses ( wfcx, def_id) ;
792+ Ok ( ( ) )
793+ } ) ) ;
779794 check_variances_for_type_defn ( tcx, def_id) ;
780795 }
781796 }
@@ -827,7 +842,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
827842 }
828843 _ => { }
829844 }
830- Ok ( ( ) )
845+ res
831846}
832847
833848pub ( super ) fn check_on_unimplemented ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) {
0 commit comments