@@ -28,11 +28,10 @@ use rustc_errors::{
28
28
} ;
29
29
use rustc_hir:: def:: DefKind ;
30
30
use rustc_hir:: def_id:: { DefId , LocalDefId } ;
31
- use rustc_hir:: intravisit:: { self , InferKind , Visitor , VisitorExt , walk_generics} ;
31
+ use rustc_hir:: intravisit:: { InferKind , Visitor , VisitorExt , walk_generics} ;
32
32
use rustc_hir:: { self as hir, GenericParamKind , HirId , Node , PreciseCapturingArgKind } ;
33
33
use rustc_infer:: infer:: { InferCtxt , TyCtxtInferExt } ;
34
34
use rustc_infer:: traits:: { DynCompatibilityViolation , ObligationCause } ;
35
- use rustc_middle:: hir:: nested_filter;
36
35
use rustc_middle:: query:: Providers ;
37
36
use rustc_middle:: ty:: util:: { Discr , IntTypeExt } ;
38
37
use rustc_middle:: ty:: { self , AdtKind , Const , IsSuggestable , Ty , TyCtxt , TypingMode , fold_regions} ;
@@ -148,10 +147,6 @@ impl<'v> Visitor<'v> for HirPlaceholderCollector {
148
147
}
149
148
}
150
149
151
- pub ( crate ) struct CollectItemTypesVisitor < ' tcx > {
152
- pub tcx : TyCtxt < ' tcx > ,
153
- }
154
-
155
150
/// If there are any placeholder types (`_`), emit an error explaining that this is not allowed
156
151
/// and suggest adding type parameters in the appropriate place, taking into consideration any and
157
152
/// all already existing generic type parameters to avoid suggesting a name that is already in use.
@@ -243,7 +238,7 @@ pub(crate) fn placeholder_type_error_diag<'cx, 'tcx>(
243
238
err
244
239
}
245
240
246
- fn reject_placeholder_type_signatures_in_item < ' tcx > (
241
+ pub ( super ) fn reject_placeholder_type_signatures_in_item < ' tcx > (
247
242
tcx : TyCtxt < ' tcx > ,
248
243
item : & ' tcx hir:: Item < ' tcx > ,
249
244
) {
@@ -274,81 +269,6 @@ fn reject_placeholder_type_signatures_in_item<'tcx>(
274
269
) ;
275
270
}
276
271
277
- impl < ' tcx > Visitor < ' tcx > for CollectItemTypesVisitor < ' tcx > {
278
- type NestedFilter = nested_filter:: OnlyBodies ;
279
-
280
- fn maybe_tcx ( & mut self ) -> Self :: MaybeTyCtxt {
281
- self . tcx
282
- }
283
-
284
- fn visit_item ( & mut self , item : & ' tcx hir:: Item < ' tcx > ) {
285
- lower_item ( self . tcx , item. item_id ( ) ) ;
286
- reject_placeholder_type_signatures_in_item ( self . tcx , item) ;
287
- intravisit:: walk_item ( self , item) ;
288
- }
289
-
290
- fn visit_generics ( & mut self , generics : & ' tcx hir:: Generics < ' tcx > ) {
291
- for param in generics. params {
292
- match param. kind {
293
- hir:: GenericParamKind :: Lifetime { .. } => { }
294
- hir:: GenericParamKind :: Type { default : Some ( _) , .. } => {
295
- self . tcx . ensure_ok ( ) . type_of ( param. def_id ) ;
296
- }
297
- hir:: GenericParamKind :: Type { .. } => { }
298
- hir:: GenericParamKind :: Const { default, .. } => {
299
- self . tcx . ensure_ok ( ) . type_of ( param. def_id ) ;
300
- if let Some ( default) = default {
301
- // need to store default and type of default
302
- self . tcx . ensure_ok ( ) . const_param_default ( param. def_id ) ;
303
- if let hir:: ConstArgKind :: Anon ( ac) = default. kind {
304
- self . tcx . ensure_ok ( ) . type_of ( ac. def_id ) ;
305
- }
306
- }
307
- }
308
- }
309
- }
310
- intravisit:: walk_generics ( self , generics) ;
311
- }
312
-
313
- fn visit_expr ( & mut self , expr : & ' tcx hir:: Expr < ' tcx > ) {
314
- if let hir:: ExprKind :: Closure ( closure) = expr. kind {
315
- self . tcx . ensure_ok ( ) . generics_of ( closure. def_id ) ;
316
- self . tcx . ensure_ok ( ) . codegen_fn_attrs ( closure. def_id ) ;
317
- // We do not call `type_of` for closures here as that
318
- // depends on typecheck and would therefore hide
319
- // any further errors in case one typeck fails.
320
- }
321
- intravisit:: walk_expr ( self , expr) ;
322
- }
323
-
324
- /// Don't call `type_of` on opaque types, since that depends on type checking function bodies.
325
- /// `check_item_type` ensures that it's called instead.
326
- fn visit_opaque_ty ( & mut self , opaque : & ' tcx hir:: OpaqueTy < ' tcx > ) {
327
- let def_id = opaque. def_id ;
328
- self . tcx . ensure_ok ( ) . generics_of ( def_id) ;
329
- self . tcx . ensure_ok ( ) . predicates_of ( def_id) ;
330
- self . tcx . ensure_ok ( ) . explicit_item_bounds ( def_id) ;
331
- self . tcx . ensure_ok ( ) . explicit_item_self_bounds ( def_id) ;
332
- self . tcx . ensure_ok ( ) . item_bounds ( def_id) ;
333
- self . tcx . ensure_ok ( ) . item_self_bounds ( def_id) ;
334
- if self . tcx . is_conditionally_const ( def_id) {
335
- self . tcx . ensure_ok ( ) . explicit_implied_const_bounds ( def_id) ;
336
- self . tcx . ensure_ok ( ) . const_conditions ( def_id) ;
337
- }
338
- intravisit:: walk_opaque_ty ( self , opaque) ;
339
- }
340
-
341
- fn visit_trait_item ( & mut self , trait_item : & ' tcx hir:: TraitItem < ' tcx > ) {
342
- lower_trait_item ( self . tcx , trait_item. trait_item_id ( ) ) ;
343
- intravisit:: walk_trait_item ( self , trait_item) ;
344
- }
345
-
346
- fn visit_impl_item ( & mut self , impl_item : & ' tcx hir:: ImplItem < ' tcx > ) {
347
- lower_impl_item ( self . tcx , impl_item. impl_item_id ( ) ) ;
348
- intravisit:: walk_impl_item ( self , impl_item) ;
349
- }
350
- }
351
-
352
272
///////////////////////////////////////////////////////////////////////////
353
273
// Utility types and common code for the above passes.
354
274
@@ -669,7 +589,7 @@ fn get_new_lifetime_name<'tcx>(
669
589
}
670
590
671
591
#[ instrument( level = "debug" , skip_all) ]
672
- fn lower_item ( tcx : TyCtxt < ' _ > , item_id : hir:: ItemId ) {
592
+ pub ( super ) fn lower_item ( tcx : TyCtxt < ' _ > , item_id : hir:: ItemId ) {
673
593
let it = tcx. hir_item ( item_id) ;
674
594
debug ! ( item = ?it. kind. ident( ) , id = %it. hir_id( ) ) ;
675
595
let def_id = item_id. owner_id . def_id ;
@@ -790,7 +710,7 @@ fn lower_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
790
710
}
791
711
}
792
712
793
- fn lower_trait_item ( tcx : TyCtxt < ' _ > , trait_item_id : hir:: TraitItemId ) {
713
+ pub ( crate ) fn lower_trait_item ( tcx : TyCtxt < ' _ > , trait_item_id : hir:: TraitItemId ) {
794
714
let trait_item = tcx. hir_trait_item ( trait_item_id) ;
795
715
let def_id = trait_item_id. owner_id ;
796
716
tcx. ensure_ok ( ) . generics_of ( def_id) ;
@@ -861,7 +781,7 @@ fn lower_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) {
861
781
tcx. ensure_ok ( ) . predicates_of ( def_id) ;
862
782
}
863
783
864
- fn lower_impl_item ( tcx : TyCtxt < ' _ > , impl_item_id : hir:: ImplItemId ) {
784
+ pub ( super ) fn lower_impl_item ( tcx : TyCtxt < ' _ > , impl_item_id : hir:: ImplItemId ) {
865
785
let def_id = impl_item_id. owner_id ;
866
786
tcx. ensure_ok ( ) . generics_of ( def_id) ;
867
787
tcx. ensure_ok ( ) . type_of ( def_id) ;
0 commit comments