@@ -207,12 +207,12 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
207
207
hir:: GenericParamKind :: Lifetime { .. } => { }
208
208
hir:: GenericParamKind :: Type { default : Some ( _) , .. } => {
209
209
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) ;
211
211
}
212
212
hir:: GenericParamKind :: Type { .. } => { }
213
213
hir:: GenericParamKind :: Const { .. } => {
214
214
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) ;
216
216
}
217
217
}
218
218
}
@@ -222,8 +222,8 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
222
222
fn visit_expr ( & mut self , expr : & ' tcx hir:: Expr < ' tcx > ) {
223
223
if let hir:: ExprKind :: Closure ( ..) = expr. kind {
224
224
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) ;
227
227
}
228
228
intravisit:: walk_expr ( self , expr) ;
229
229
}
@@ -635,47 +635,47 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) {
635
635
hir:: ItemKind :: ForeignMod ( ref foreign_mod) => {
636
636
for item in foreign_mod. items {
637
637
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) ;
641
641
if let hir:: ForeignItemKind :: Fn ( ..) = item. kind {
642
- tcx. fn_sig ( def_id) ;
642
+ tcx. ensure ( ) . fn_sig ( def_id) ;
643
643
}
644
644
}
645
645
}
646
646
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) ;
650
650
convert_enum_variant_types ( tcx, def_id. to_def_id ( ) , & enum_definition. variants ) ;
651
651
}
652
652
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) ;
657
657
}
658
658
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) ;
661
661
tcx. at ( it. span ) . super_predicates_of ( def_id) ;
662
- tcx. predicates_of ( def_id) ;
662
+ tcx. ensure ( ) . predicates_of ( def_id) ;
663
663
}
664
664
hir:: ItemKind :: TraitAlias ( ..) => {
665
- tcx. generics_of ( def_id) ;
665
+ tcx. ensure ( ) . generics_of ( def_id) ;
666
666
tcx. at ( it. span ) . super_predicates_of ( def_id) ;
667
- tcx. predicates_of ( def_id) ;
667
+ tcx. ensure ( ) . predicates_of ( def_id) ;
668
668
}
669
669
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) ;
673
673
674
674
for f in struct_def. fields ( ) {
675
675
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) ;
679
679
}
680
680
681
681
if let Some ( ctor_hir_id) = struct_def. ctor_hir_id ( ) {
@@ -691,11 +691,11 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) {
691
691
| hir:: ItemKind :: Static ( ..)
692
692
| hir:: ItemKind :: Const ( ..)
693
693
| 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) ;
697
697
if let hir:: ItemKind :: Fn ( ..) = it. kind {
698
- tcx. fn_sig ( def_id) ;
698
+ tcx. ensure ( ) . fn_sig ( def_id) ;
699
699
}
700
700
}
701
701
}
@@ -704,20 +704,20 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) {
704
704
fn convert_trait_item ( tcx : TyCtxt < ' _ > , trait_item_id : hir:: HirId ) {
705
705
let trait_item = tcx. hir ( ) . expect_trait_item ( trait_item_id) ;
706
706
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) ;
708
708
709
709
match trait_item. kind {
710
710
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) ;
713
713
}
714
714
715
715
hir:: TraitItemKind :: Const ( .., Some ( _) ) => {
716
- tcx. type_of ( def_id) ;
716
+ tcx. ensure ( ) . type_of ( def_id) ;
717
717
}
718
718
719
719
hir:: TraitItemKind :: Const ( ..) | hir:: TraitItemKind :: Type ( _, Some ( _) ) => {
720
- tcx. type_of ( def_id) ;
720
+ tcx. ensure ( ) . type_of ( def_id) ;
721
721
// Account for `const C: _;` and `type T = _;`.
722
722
let mut visitor = PlaceholderHirTyCollector :: default ( ) ;
723
723
visitor. visit_trait_item ( trait_item) ;
@@ -727,18 +727,18 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) {
727
727
hir:: TraitItemKind :: Type ( _, None ) => { }
728
728
} ;
729
729
730
- tcx. predicates_of ( def_id) ;
730
+ tcx. ensure ( ) . predicates_of ( def_id) ;
731
731
}
732
732
733
733
fn convert_impl_item ( tcx : TyCtxt < ' _ > , impl_item_id : hir:: HirId ) {
734
734
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) ;
738
738
let impl_item = tcx. hir ( ) . expect_impl_item ( impl_item_id) ;
739
739
match impl_item. kind {
740
740
hir:: ImplItemKind :: Fn ( ..) => {
741
- tcx. fn_sig ( def_id) ;
741
+ tcx. ensure ( ) . fn_sig ( def_id) ;
742
742
}
743
743
hir:: ImplItemKind :: TyAlias ( _) | hir:: ImplItemKind :: OpaqueTy ( _) => {
744
744
// Account for `type T = _;`
@@ -752,9 +752,9 @@ fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::HirId) {
752
752
753
753
fn convert_variant_ctor ( tcx : TyCtxt < ' _ > , ctor_id : hir:: HirId ) {
754
754
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) ;
758
758
}
759
759
760
760
fn 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
790
790
791
791
for f in variant. data . fields ( ) {
792
792
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) ;
796
796
}
797
797
798
798
// Convert the ctor, if any. This also registers the variant as
0 commit comments