@@ -207,12 +207,12 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
207207 hir:: GenericParamKind :: Lifetime { .. } => { }
208208 hir:: GenericParamKind :: Type { default : Some ( _) , .. } => {
209209 let def_id = self . tcx . hir ( ) . local_def_id ( param. hir_id ) ;
210- self . tcx . type_of ( def_id) ;
210+ self . tcx . ensure ( ) . type_of ( def_id) ;
211211 }
212212 hir:: GenericParamKind :: Type { .. } => { }
213213 hir:: GenericParamKind :: Const { .. } => {
214214 let def_id = self . tcx . hir ( ) . local_def_id ( param. hir_id ) ;
215- self . tcx . type_of ( def_id) ;
215+ self . tcx . ensure ( ) . type_of ( def_id) ;
216216 }
217217 }
218218 }
@@ -222,8 +222,8 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
222222 fn visit_expr ( & mut self , expr : & ' tcx hir:: Expr < ' tcx > ) {
223223 if let hir:: ExprKind :: Closure ( ..) = expr. kind {
224224 let def_id = self . tcx . hir ( ) . local_def_id ( expr. hir_id ) ;
225- self . tcx . generics_of ( def_id) ;
226- self . tcx . type_of ( def_id) ;
225+ self . tcx . ensure ( ) . generics_of ( def_id) ;
226+ self . tcx . ensure ( ) . type_of ( def_id) ;
227227 }
228228 intravisit:: walk_expr ( self , expr) ;
229229 }
@@ -635,47 +635,47 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) {
635635 hir:: ItemKind :: ForeignMod ( ref foreign_mod) => {
636636 for item in foreign_mod. items {
637637 let def_id = tcx. hir ( ) . local_def_id ( item. hir_id ) ;
638- tcx. generics_of ( def_id) ;
639- tcx. type_of ( def_id) ;
640- tcx. predicates_of ( def_id) ;
638+ tcx. ensure ( ) . generics_of ( def_id) ;
639+ tcx. ensure ( ) . type_of ( def_id) ;
640+ tcx. ensure ( ) . predicates_of ( def_id) ;
641641 if let hir:: ForeignItemKind :: Fn ( ..) = item. kind {
642- tcx. fn_sig ( def_id) ;
642+ tcx. ensure ( ) . fn_sig ( def_id) ;
643643 }
644644 }
645645 }
646646 hir:: ItemKind :: Enum ( ref enum_definition, _) => {
647- tcx. generics_of ( def_id) ;
648- tcx. type_of ( def_id) ;
649- tcx. predicates_of ( def_id) ;
647+ tcx. ensure ( ) . generics_of ( def_id) ;
648+ tcx. ensure ( ) . type_of ( def_id) ;
649+ tcx. ensure ( ) . predicates_of ( def_id) ;
650650 convert_enum_variant_types ( tcx, def_id. to_def_id ( ) , & enum_definition. variants ) ;
651651 }
652652 hir:: ItemKind :: Impl { .. } => {
653- tcx. generics_of ( def_id) ;
654- tcx. type_of ( def_id) ;
655- tcx. impl_trait_ref ( def_id) ;
656- tcx. predicates_of ( def_id) ;
653+ tcx. ensure ( ) . generics_of ( def_id) ;
654+ tcx. ensure ( ) . type_of ( def_id) ;
655+ tcx. ensure ( ) . impl_trait_ref ( def_id) ;
656+ tcx. ensure ( ) . predicates_of ( def_id) ;
657657 }
658658 hir:: ItemKind :: Trait ( ..) => {
659- tcx. generics_of ( def_id) ;
660- tcx. trait_def ( def_id) ;
659+ tcx. ensure ( ) . generics_of ( def_id) ;
660+ tcx. ensure ( ) . trait_def ( def_id) ;
661661 tcx. at ( it. span ) . super_predicates_of ( def_id) ;
662- tcx. predicates_of ( def_id) ;
662+ tcx. ensure ( ) . predicates_of ( def_id) ;
663663 }
664664 hir:: ItemKind :: TraitAlias ( ..) => {
665- tcx. generics_of ( def_id) ;
665+ tcx. ensure ( ) . generics_of ( def_id) ;
666666 tcx. at ( it. span ) . super_predicates_of ( def_id) ;
667- tcx. predicates_of ( def_id) ;
667+ tcx. ensure ( ) . predicates_of ( def_id) ;
668668 }
669669 hir:: ItemKind :: Struct ( ref struct_def, _) | hir:: ItemKind :: Union ( ref struct_def, _) => {
670- tcx. generics_of ( def_id) ;
671- tcx. type_of ( def_id) ;
672- tcx. predicates_of ( def_id) ;
670+ tcx. ensure ( ) . generics_of ( def_id) ;
671+ tcx. ensure ( ) . type_of ( def_id) ;
672+ tcx. ensure ( ) . predicates_of ( def_id) ;
673673
674674 for f in struct_def. fields ( ) {
675675 let def_id = tcx. hir ( ) . local_def_id ( f. hir_id ) ;
676- tcx. generics_of ( def_id) ;
677- tcx. type_of ( def_id) ;
678- tcx. predicates_of ( def_id) ;
676+ tcx. ensure ( ) . generics_of ( def_id) ;
677+ tcx. ensure ( ) . type_of ( def_id) ;
678+ tcx. ensure ( ) . predicates_of ( def_id) ;
679679 }
680680
681681 if let Some ( ctor_hir_id) = struct_def. ctor_hir_id ( ) {
@@ -691,11 +691,11 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) {
691691 | hir:: ItemKind :: Static ( ..)
692692 | hir:: ItemKind :: Const ( ..)
693693 | hir:: ItemKind :: Fn ( ..) => {
694- tcx. generics_of ( def_id) ;
695- tcx. type_of ( def_id) ;
696- tcx. predicates_of ( def_id) ;
694+ tcx. ensure ( ) . generics_of ( def_id) ;
695+ tcx. ensure ( ) . type_of ( def_id) ;
696+ tcx. ensure ( ) . predicates_of ( def_id) ;
697697 if let hir:: ItemKind :: Fn ( ..) = it. kind {
698- tcx. fn_sig ( def_id) ;
698+ tcx. ensure ( ) . fn_sig ( def_id) ;
699699 }
700700 }
701701 }
@@ -704,20 +704,20 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) {
704704fn convert_trait_item ( tcx : TyCtxt < ' _ > , trait_item_id : hir:: HirId ) {
705705 let trait_item = tcx. hir ( ) . expect_trait_item ( trait_item_id) ;
706706 let def_id = tcx. hir ( ) . local_def_id ( trait_item. hir_id ) ;
707- tcx. generics_of ( def_id) ;
707+ tcx. ensure ( ) . generics_of ( def_id) ;
708708
709709 match trait_item. kind {
710710 hir:: TraitItemKind :: Fn ( ..) => {
711- tcx. type_of ( def_id) ;
712- tcx. fn_sig ( def_id) ;
711+ tcx. ensure ( ) . type_of ( def_id) ;
712+ tcx. ensure ( ) . fn_sig ( def_id) ;
713713 }
714714
715715 hir:: TraitItemKind :: Const ( .., Some ( _) ) => {
716- tcx. type_of ( def_id) ;
716+ tcx. ensure ( ) . type_of ( def_id) ;
717717 }
718718
719719 hir:: TraitItemKind :: Const ( ..) | hir:: TraitItemKind :: Type ( _, Some ( _) ) => {
720- tcx. type_of ( def_id) ;
720+ tcx. ensure ( ) . type_of ( def_id) ;
721721 // Account for `const C: _;` and `type T = _;`.
722722 let mut visitor = PlaceholderHirTyCollector :: default ( ) ;
723723 visitor. visit_trait_item ( trait_item) ;
@@ -727,18 +727,18 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) {
727727 hir:: TraitItemKind :: Type ( _, None ) => { }
728728 } ;
729729
730- tcx. predicates_of ( def_id) ;
730+ tcx. ensure ( ) . predicates_of ( def_id) ;
731731}
732732
733733fn convert_impl_item ( tcx : TyCtxt < ' _ > , impl_item_id : hir:: HirId ) {
734734 let def_id = tcx. hir ( ) . local_def_id ( impl_item_id) ;
735- tcx. generics_of ( def_id) ;
736- tcx. type_of ( def_id) ;
737- tcx. predicates_of ( def_id) ;
735+ tcx. ensure ( ) . generics_of ( def_id) ;
736+ tcx. ensure ( ) . type_of ( def_id) ;
737+ tcx. ensure ( ) . predicates_of ( def_id) ;
738738 let impl_item = tcx. hir ( ) . expect_impl_item ( impl_item_id) ;
739739 match impl_item. kind {
740740 hir:: ImplItemKind :: Fn ( ..) => {
741- tcx. fn_sig ( def_id) ;
741+ tcx. ensure ( ) . fn_sig ( def_id) ;
742742 }
743743 hir:: ImplItemKind :: TyAlias ( _) | hir:: ImplItemKind :: OpaqueTy ( _) => {
744744 // Account for `type T = _;`
@@ -752,9 +752,9 @@ fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::HirId) {
752752
753753fn convert_variant_ctor ( tcx : TyCtxt < ' _ > , ctor_id : hir:: HirId ) {
754754 let def_id = tcx. hir ( ) . local_def_id ( ctor_id) ;
755- tcx. generics_of ( def_id) ;
756- tcx. type_of ( def_id) ;
757- tcx. predicates_of ( def_id) ;
755+ tcx. ensure ( ) . generics_of ( def_id) ;
756+ tcx. ensure ( ) . type_of ( def_id) ;
757+ tcx. ensure ( ) . predicates_of ( def_id) ;
758758}
759759
760760fn convert_enum_variant_types ( tcx : TyCtxt < ' _ > , def_id : DefId , variants : & [ hir:: Variant < ' _ > ] ) {
@@ -790,9 +790,9 @@ fn convert_enum_variant_types(tcx: TyCtxt<'_>, def_id: DefId, variants: &[hir::V
790790
791791 for f in variant. data . fields ( ) {
792792 let def_id = tcx. hir ( ) . local_def_id ( f. hir_id ) ;
793- tcx. generics_of ( def_id) ;
794- tcx. type_of ( def_id) ;
795- tcx. predicates_of ( def_id) ;
793+ tcx. ensure ( ) . generics_of ( def_id) ;
794+ tcx. ensure ( ) . type_of ( def_id) ;
795+ tcx. ensure ( ) . predicates_of ( def_id) ;
796796 }
797797
798798 // Convert the ctor, if any. This also registers the variant as
0 commit comments