1
1
use crate :: autoderef:: Autoderef ;
2
+ use crate :: collect:: CollectItemTypesVisitor ;
2
3
use crate :: constrained_generic_params:: { identify_constrained_generic_params, Parameter } ;
3
4
use crate :: errors;
4
5
6
+ use hir:: intravisit:: Visitor ;
5
7
use rustc_ast as ast;
6
8
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexSet } ;
7
9
use 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<()
225
227
?item. owner_id,
226
228
item. name = ? tcx. def_path_str( def_id)
227
229
) ;
230
+ CollectItemTypesVisitor { tcx } . visit_item ( item) ;
228
231
229
232
let res = match item. kind {
230
233
// 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<()
336
339
res
337
340
}
338
341
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 > {
340
346
let def_id = item. owner_id . def_id ;
341
347
348
+ CollectItemTypesVisitor { tcx } . visit_foreign_item ( item) ;
349
+
342
350
debug ! (
343
351
?item. owner_id,
344
352
item. name = ? tcx. def_path_str( def_id)
@@ -355,12 +363,14 @@ fn check_foreign_item(tcx: TyCtxt<'_>, item: &hir::ForeignItem<'_>) -> Result<()
355
363
}
356
364
}
357
365
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 > ,
361
369
) -> Result < ( ) , ErrorGuaranteed > {
362
370
let def_id = trait_item. owner_id . def_id ;
363
371
372
+ CollectItemTypesVisitor { tcx } . visit_trait_item ( trait_item) ;
373
+
364
374
let ( method_sig, span) = match trait_item. kind {
365
375
hir:: TraitItemKind :: Fn ( ref sig, _) => ( Some ( sig) , trait_item. span ) ,
366
376
hir:: TraitItemKind :: Type ( _bounds, Some ( ty) ) => ( None , ty. span ) ,
@@ -897,7 +907,12 @@ fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem
897
907
}
898
908
}
899
909
900
- fn check_impl_item ( tcx : TyCtxt < ' _ > , impl_item : & hir:: ImplItem < ' _ > ) -> Result < ( ) , ErrorGuaranteed > {
910
+ fn check_impl_item < ' tcx > (
911
+ tcx : TyCtxt < ' tcx > ,
912
+ impl_item : & ' tcx hir:: ImplItem < ' tcx > ,
913
+ ) -> Result < ( ) , ErrorGuaranteed > {
914
+ CollectItemTypesVisitor { tcx } . visit_impl_item ( impl_item) ;
915
+
901
916
let ( method_sig, span) = match impl_item. kind {
902
917
hir:: ImplItemKind :: Fn ( ref sig, _) => ( Some ( sig) , impl_item. span ) ,
903
918
// Constrain binding and overflow error spans to `<Ty>` in `type foo = <Ty>`.
0 commit comments