@@ -758,17 +758,34 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
758
758
}
759
759
760
760
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
+ }
765
774
}
766
- DefKind :: Const => { }
767
775
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 ( ) ) ;
768
780
check_enum ( tcx, def_id) ;
769
781
check_variances_for_type_defn ( tcx, def_id) ;
770
782
}
771
783
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) ;
772
789
if let Some ( i) = tcx. intrinsic ( def_id) {
773
790
intrinsic:: check_intrinsic_type (
774
791
tcx,
@@ -779,6 +796,11 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
779
796
}
780
797
}
781
798
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) ;
782
804
if of_trait && let Some ( impl_trait_header) = tcx. impl_trait_header ( def_id) {
783
805
tcx. ensure_ok ( )
784
806
. 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<(),
787
809
}
788
810
}
789
811
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) ;
790
817
let assoc_items = tcx. associated_items ( def_id) ;
791
818
check_on_unimplemented ( tcx, def_id) ;
792
819
@@ -805,12 +832,32 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
805
832
}
806
833
}
807
834
}
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) ;
811
840
}
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
+ }
814
861
check_variances_for_type_defn ( tcx, def_id) ;
815
862
}
816
863
DefKind :: OpaqueTy => {
@@ -838,6 +885,9 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
838
885
}
839
886
}
840
887
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) ;
841
891
check_type_alias_type_params_are_used ( tcx, def_id) ;
842
892
if tcx. type_alias_is_lazy ( def_id) {
843
893
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<(),
897
947
}
898
948
899
949
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 ) ;
902
961
require_c_abi_if_c_variadic ( tcx, sig. decl , abi, item. span ) ;
903
962
}
904
- _ => { }
963
+ hir:: ForeignItemKind :: Static ( ..) => {
964
+ tcx. ensure_ok ( ) . codegen_fn_attrs ( item. owner_id ) ;
965
+ }
966
+ _ => ( ) ,
905
967
}
906
968
}
907
969
}
0 commit comments