@@ -758,17 +758,34 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
758758 }
759759
760760 match tcx. def_kind ( def_id) {
761- DefKind :: Static { .. } => {
762- check_static_inhabited ( tcx, def_id) ;
763- check_static_linkage ( tcx, def_id) ;
764- wfcheck:: check_static_item ( tcx, def_id) ?;
761+ def_kind @ ( DefKind :: Static { .. } | DefKind :: Const ) => {
762+ tcx. ensure_ok ( ) . generics_of ( def_id) ;
763+ tcx. ensure_ok ( ) . type_of ( def_id) ;
764+ tcx. ensure_ok ( ) . predicates_of ( def_id) ;
765+ match def_kind {
766+ DefKind :: Static { .. } => {
767+ check_static_inhabited ( tcx, def_id) ;
768+ check_static_linkage ( tcx, def_id) ;
769+ wfcheck:: check_static_item ( tcx, def_id) ?;
770+ }
771+ DefKind :: Const => { }
772+ _ => unreachable ! ( ) ,
773+ }
765774 }
766- DefKind :: Const => { }
767775 DefKind :: Enum => {
776+ tcx. ensure_ok ( ) . generics_of ( def_id) ;
777+ tcx. ensure_ok ( ) . type_of ( def_id) ;
778+ tcx. ensure_ok ( ) . predicates_of ( def_id) ;
779+ crate :: collect:: lower_enum_variant_types ( tcx, def_id. to_def_id ( ) ) ;
768780 check_enum ( tcx, def_id) ;
769781 check_variances_for_type_defn ( tcx, def_id) ;
770782 }
771783 DefKind :: Fn => {
784+ tcx. ensure_ok ( ) . generics_of ( def_id) ;
785+ tcx. ensure_ok ( ) . type_of ( def_id) ;
786+ tcx. ensure_ok ( ) . predicates_of ( def_id) ;
787+ tcx. ensure_ok ( ) . fn_sig ( def_id) ;
788+ tcx. ensure_ok ( ) . codegen_fn_attrs ( def_id) ;
772789 if let Some ( i) = tcx. intrinsic ( def_id) {
773790 intrinsic:: check_intrinsic_type (
774791 tcx,
@@ -779,6 +796,11 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
779796 }
780797 }
781798 DefKind :: Impl { of_trait } => {
799+ tcx. ensure_ok ( ) . generics_of ( def_id) ;
800+ tcx. ensure_ok ( ) . type_of ( def_id) ;
801+ tcx. ensure_ok ( ) . impl_trait_header ( def_id) ;
802+ tcx. ensure_ok ( ) . predicates_of ( def_id) ;
803+ tcx. ensure_ok ( ) . associated_items ( def_id) ;
782804 if of_trait && let Some ( impl_trait_header) = tcx. impl_trait_header ( def_id) {
783805 tcx. ensure_ok ( )
784806 . coherent_trait ( impl_trait_header. trait_ref . instantiate_identity ( ) . def_id ) ?;
@@ -787,6 +809,11 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
787809 }
788810 }
789811 DefKind :: Trait => {
812+ tcx. ensure_ok ( ) . generics_of ( def_id) ;
813+ tcx. ensure_ok ( ) . trait_def ( def_id) ;
814+ tcx. ensure_ok ( ) . explicit_super_predicates_of ( def_id) ;
815+ tcx. ensure_ok ( ) . predicates_of ( def_id) ;
816+ tcx. ensure_ok ( ) . associated_items ( def_id) ;
790817 let assoc_items = tcx. associated_items ( def_id) ;
791818 check_on_unimplemented ( tcx, def_id) ;
792819
@@ -805,12 +832,32 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
805832 }
806833 }
807834 }
808- DefKind :: Struct => {
809- check_struct ( tcx, def_id) ;
810- check_variances_for_type_defn ( tcx, def_id) ;
835+ DefKind :: TraitAlias => {
836+ tcx. ensure_ok ( ) . generics_of ( def_id) ;
837+ tcx. ensure_ok ( ) . explicit_implied_predicates_of ( def_id) ;
838+ tcx. ensure_ok ( ) . explicit_super_predicates_of ( def_id) ;
839+ tcx. ensure_ok ( ) . predicates_of ( def_id) ;
811840 }
812- DefKind :: Union => {
813- check_union ( tcx, def_id) ;
841+ def_kind @ ( DefKind :: Struct | DefKind :: Union ) => {
842+ tcx. ensure_ok ( ) . generics_of ( def_id) ;
843+ tcx. ensure_ok ( ) . type_of ( def_id) ;
844+ tcx. ensure_ok ( ) . predicates_of ( def_id) ;
845+
846+ let adt = tcx. adt_def ( def_id) . non_enum_variant ( ) ;
847+ for f in adt. fields . iter ( ) {
848+ tcx. ensure_ok ( ) . generics_of ( f. did ) ;
849+ tcx. ensure_ok ( ) . type_of ( f. did ) ;
850+ tcx. ensure_ok ( ) . predicates_of ( f. did ) ;
851+ }
852+
853+ if let Some ( ( _, ctor_def_id) ) = adt. ctor {
854+ crate :: collect:: lower_variant_ctor ( tcx, ctor_def_id. expect_local ( ) ) ;
855+ }
856+ match def_kind {
857+ DefKind :: Struct => check_struct ( tcx, def_id) ,
858+ DefKind :: Union => check_union ( tcx, def_id) ,
859+ _ => unreachable ! ( ) ,
860+ }
814861 check_variances_for_type_defn ( tcx, def_id) ;
815862 }
816863 DefKind :: OpaqueTy => {
@@ -838,6 +885,9 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
838885 }
839886 }
840887 DefKind :: TyAlias => {
888+ tcx. ensure_ok ( ) . generics_of ( def_id) ;
889+ tcx. ensure_ok ( ) . type_of ( def_id) ;
890+ tcx. ensure_ok ( ) . predicates_of ( def_id) ;
841891 check_type_alias_type_params_are_used ( tcx, def_id) ;
842892 if tcx. type_alias_is_lazy ( def_id) {
843893 res = res. and ( enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
@@ -897,11 +947,23 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
897947 }
898948
899949 let item = tcx. hir_foreign_item ( item. id ) ;
900- match & item. kind {
901- hir:: ForeignItemKind :: Fn ( sig, _, _) => {
950+ tcx. ensure_ok ( ) . generics_of ( item. owner_id ) ;
951+ tcx. ensure_ok ( ) . type_of ( item. owner_id ) ;
952+ tcx. ensure_ok ( ) . predicates_of ( item. owner_id ) ;
953+ if tcx. is_conditionally_const ( def_id) {
954+ tcx. ensure_ok ( ) . explicit_implied_const_bounds ( def_id) ;
955+ tcx. ensure_ok ( ) . const_conditions ( def_id) ;
956+ }
957+ match item. kind {
958+ hir:: ForeignItemKind :: Fn ( sig, ..) => {
959+ tcx. ensure_ok ( ) . codegen_fn_attrs ( item. owner_id ) ;
960+ tcx. ensure_ok ( ) . fn_sig ( item. owner_id ) ;
902961 require_c_abi_if_c_variadic ( tcx, sig. decl , abi, item. span ) ;
903962 }
904- _ => { }
963+ hir:: ForeignItemKind :: Static ( ..) => {
964+ tcx. ensure_ok ( ) . codegen_fn_attrs ( item. owner_id ) ;
965+ }
966+ _ => ( ) ,
905967 }
906968 }
907969 }
0 commit comments