11use crate :: autoderef:: Autoderef ;
2+ use crate :: collect:: CollectItemTypesVisitor ;
23use crate :: constrained_generic_params:: { identify_constrained_generic_params, Parameter } ;
34use crate :: errors;
45
6+ use hir:: intravisit:: Visitor ;
57use rustc_ast as ast;
68use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexSet } ;
79use rustc_errors:: { codes:: * , pluralize, struct_span_code_err, Applicability , ErrorGuaranteed } ;
@@ -225,6 +227,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
225227 ?item. owner_id,
226228 item. name = ? tcx. def_path_str( def_id)
227229 ) ;
230+ CollectItemTypesVisitor { tcx } . visit_item ( item) ;
228231
229232 let res = match item. kind {
230233 // Right now we check that every default trait implementation
@@ -336,9 +339,14 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
336339 res
337340}
338341
339- fn check_foreign_item ( tcx : TyCtxt < ' _ > , item : & hir:: ForeignItem < ' _ > ) -> Result < ( ) , ErrorGuaranteed > {
342+ fn check_foreign_item < ' tcx > (
343+ tcx : TyCtxt < ' tcx > ,
344+ item : & ' tcx hir:: ForeignItem < ' tcx > ,
345+ ) -> Result < ( ) , ErrorGuaranteed > {
340346 let def_id = item. owner_id . def_id ;
341347
348+ CollectItemTypesVisitor { tcx } . visit_foreign_item ( item) ;
349+
342350 debug ! (
343351 ?item. owner_id,
344352 item. name = ? tcx. def_path_str( def_id)
@@ -355,12 +363,14 @@ fn check_foreign_item(tcx: TyCtxt<'_>, item: &hir::ForeignItem<'_>) -> Result<()
355363 }
356364}
357365
358- fn check_trait_item (
359- tcx : TyCtxt < ' _ > ,
360- trait_item : & hir:: TraitItem < ' _ > ,
366+ fn check_trait_item < ' tcx > (
367+ tcx : TyCtxt < ' tcx > ,
368+ trait_item : & ' tcx hir:: TraitItem < ' tcx > ,
361369) -> Result < ( ) , ErrorGuaranteed > {
362370 let def_id = trait_item. owner_id . def_id ;
363371
372+ CollectItemTypesVisitor { tcx } . visit_trait_item ( trait_item) ;
373+
364374 let ( method_sig, span) = match trait_item. kind {
365375 hir:: TraitItemKind :: Fn ( ref sig, _) => ( Some ( sig) , trait_item. span ) ,
366376 hir:: TraitItemKind :: Type ( _bounds, Some ( ty) ) => ( None , ty. span ) ,
@@ -895,7 +905,12 @@ fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem
895905 }
896906}
897907
898- fn check_impl_item ( tcx : TyCtxt < ' _ > , impl_item : & hir:: ImplItem < ' _ > ) -> Result < ( ) , ErrorGuaranteed > {
908+ fn check_impl_item < ' tcx > (
909+ tcx : TyCtxt < ' tcx > ,
910+ impl_item : & ' tcx hir:: ImplItem < ' tcx > ,
911+ ) -> Result < ( ) , ErrorGuaranteed > {
912+ CollectItemTypesVisitor { tcx } . visit_impl_item ( impl_item) ;
913+
899914 let ( method_sig, span) = match impl_item. kind {
900915 hir:: ImplItemKind :: Fn ( ref sig, _) => ( Some ( sig) , impl_item. span ) ,
901916 // Constrain binding and overflow error spans to `<Ty>` in `type foo = <Ty>`.
0 commit comments