@@ -28,11 +28,10 @@ use rustc_errors::{
2828} ;
2929use rustc_hir:: def:: DefKind ;
3030use 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} ;
3232use rustc_hir:: { self as hir, GenericParamKind , HirId , Node , PreciseCapturingArgKind } ;
3333use rustc_infer:: infer:: { InferCtxt , TyCtxtInferExt } ;
3434use rustc_infer:: traits:: { DynCompatibilityViolation , ObligationCause } ;
35- use rustc_middle:: hir:: nested_filter;
3635use rustc_middle:: query:: Providers ;
3736use rustc_middle:: ty:: util:: { Discr , IntTypeExt } ;
3837use rustc_middle:: ty:: { self , AdtKind , Const , IsSuggestable , Ty , TyCtxt , TypingMode , fold_regions} ;
@@ -148,10 +147,6 @@ impl<'v> Visitor<'v> for HirPlaceholderCollector {
148147 }
149148}
150149
151- pub ( crate ) struct CollectItemTypesVisitor < ' tcx > {
152- pub tcx : TyCtxt < ' tcx > ,
153- }
154-
155150/// If there are any placeholder types (`_`), emit an error explaining that this is not allowed
156151/// and suggest adding type parameters in the appropriate place, taking into consideration any and
157152/// 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>(
243238 err
244239}
245240
246- fn reject_placeholder_type_signatures_in_item < ' tcx > (
241+ pub ( super ) fn reject_placeholder_type_signatures_in_item < ' tcx > (
247242 tcx : TyCtxt < ' tcx > ,
248243 item : & ' tcx hir:: Item < ' tcx > ,
249244) {
@@ -274,81 +269,6 @@ fn reject_placeholder_type_signatures_in_item<'tcx>(
274269 ) ;
275270}
276271
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-
352272///////////////////////////////////////////////////////////////////////////
353273// Utility types and common code for the above passes.
354274
@@ -669,7 +589,7 @@ fn get_new_lifetime_name<'tcx>(
669589}
670590
671591#[ 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 ) {
673593 let it = tcx. hir_item ( item_id) ;
674594 debug ! ( item = ?it. kind. ident( ) , id = %it. hir_id( ) ) ;
675595 let def_id = item_id. owner_id . def_id ;
@@ -790,7 +710,7 @@ fn lower_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
790710 }
791711}
792712
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 ) {
794714 let trait_item = tcx. hir_trait_item ( trait_item_id) ;
795715 let def_id = trait_item_id. owner_id ;
796716 tcx. ensure_ok ( ) . generics_of ( def_id) ;
@@ -861,7 +781,7 @@ fn lower_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) {
861781 tcx. ensure_ok ( ) . predicates_of ( def_id) ;
862782}
863783
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 ) {
865785 let def_id = impl_item_id. owner_id ;
866786 tcx. ensure_ok ( ) . generics_of ( def_id) ;
867787 tcx. ensure_ok ( ) . type_of ( def_id) ;
0 commit comments