@@ -792,21 +792,15 @@ impl<'a> LintContext for EarlyContext<'a> {
792
792
}
793
793
}
794
794
795
- impl < ' a , ' tcx , ' v > hir_visit:: Visitor < ' v > for LateContext < ' a , ' tcx > {
795
+ impl < ' a , ' tcx > hir_visit:: Visitor < ' tcx > for LateContext < ' a , ' tcx > {
796
796
/// Because lints are scoped lexically, we want to walk nested
797
797
/// items in the context of the outer item, so enable
798
798
/// deep-walking.
799
- fn visit_nested_item ( & mut self , item : hir:: ItemId ) {
800
- let item = self . tcx . map . expect_item ( item. id ) ;
801
- self . visit_item ( item)
799
+ fn nested_visit_map ( & mut self ) -> Option < & hir:: map:: Map < ' tcx > > {
800
+ Some ( & self . tcx . map )
802
801
}
803
802
804
- fn visit_nested_impl_item ( & mut self , item_id : hir:: ImplItemId ) {
805
- let impl_item = self . tcx . map . impl_item ( item_id) ;
806
- self . visit_impl_item ( impl_item)
807
- }
808
-
809
- fn visit_item ( & mut self , it : & hir:: Item ) {
803
+ fn visit_item ( & mut self , it : & ' tcx hir:: Item ) {
810
804
self . with_lint_attrs ( & it. attrs , |cx| {
811
805
run_lints ! ( cx, check_item, late_passes, it) ;
812
806
cx. visit_ids ( |v| v. visit_item ( it) ) ;
@@ -815,27 +809,27 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
815
809
} )
816
810
}
817
811
818
- fn visit_foreign_item ( & mut self , it : & hir:: ForeignItem ) {
812
+ fn visit_foreign_item ( & mut self , it : & ' tcx hir:: ForeignItem ) {
819
813
self . with_lint_attrs ( & it. attrs , |cx| {
820
814
run_lints ! ( cx, check_foreign_item, late_passes, it) ;
821
815
hir_visit:: walk_foreign_item ( cx, it) ;
822
816
run_lints ! ( cx, check_foreign_item_post, late_passes, it) ;
823
817
} )
824
818
}
825
819
826
- fn visit_pat ( & mut self , p : & hir:: Pat ) {
820
+ fn visit_pat ( & mut self , p : & ' tcx hir:: Pat ) {
827
821
run_lints ! ( self , check_pat, late_passes, p) ;
828
822
hir_visit:: walk_pat ( self , p) ;
829
823
}
830
824
831
- fn visit_expr ( & mut self , e : & hir:: Expr ) {
825
+ fn visit_expr ( & mut self , e : & ' tcx hir:: Expr ) {
832
826
self . with_lint_attrs ( & e. attrs , |cx| {
833
827
run_lints ! ( cx, check_expr, late_passes, e) ;
834
828
hir_visit:: walk_expr ( cx, e) ;
835
829
} )
836
830
}
837
831
838
- fn visit_stmt ( & mut self , s : & hir:: Stmt ) {
832
+ fn visit_stmt ( & mut self , s : & ' tcx hir:: Stmt ) {
839
833
// statement attributes are actually just attributes on one of
840
834
// - item
841
835
// - local
@@ -845,40 +839,43 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
845
839
hir_visit:: walk_stmt ( self , s) ;
846
840
}
847
841
848
- fn visit_fn ( & mut self , fk : hir_visit:: FnKind < ' v > , decl : & ' v hir:: FnDecl ,
849
- body : & ' v hir:: Expr , span : Span , id : ast:: NodeId ) {
842
+ fn visit_fn ( & mut self , fk : hir_visit:: FnKind < ' tcx > , decl : & ' tcx hir:: FnDecl ,
843
+ body : & ' tcx hir:: Expr , span : Span , id : ast:: NodeId ) {
850
844
run_lints ! ( self , check_fn, late_passes, fk, decl, body, span, id) ;
851
845
hir_visit:: walk_fn ( self , fk, decl, body, span, id) ;
852
846
run_lints ! ( self , check_fn_post, late_passes, fk, decl, body, span, id) ;
853
847
}
854
848
855
849
fn visit_variant_data ( & mut self ,
856
- s : & hir:: VariantData ,
850
+ s : & ' tcx hir:: VariantData ,
857
851
name : ast:: Name ,
858
- g : & hir:: Generics ,
852
+ g : & ' tcx hir:: Generics ,
859
853
item_id : ast:: NodeId ,
860
854
_: Span ) {
861
855
run_lints ! ( self , check_struct_def, late_passes, s, name, g, item_id) ;
862
856
hir_visit:: walk_struct_def ( self , s) ;
863
857
run_lints ! ( self , check_struct_def_post, late_passes, s, name, g, item_id) ;
864
858
}
865
859
866
- fn visit_struct_field ( & mut self , s : & hir:: StructField ) {
860
+ fn visit_struct_field ( & mut self , s : & ' tcx hir:: StructField ) {
867
861
self . with_lint_attrs ( & s. attrs , |cx| {
868
862
run_lints ! ( cx, check_struct_field, late_passes, s) ;
869
863
hir_visit:: walk_struct_field ( cx, s) ;
870
864
} )
871
865
}
872
866
873
- fn visit_variant ( & mut self , v : & hir:: Variant , g : & hir:: Generics , item_id : ast:: NodeId ) {
867
+ fn visit_variant ( & mut self ,
868
+ v : & ' tcx hir:: Variant ,
869
+ g : & ' tcx hir:: Generics ,
870
+ item_id : ast:: NodeId ) {
874
871
self . with_lint_attrs ( & v. node . attrs , |cx| {
875
872
run_lints ! ( cx, check_variant, late_passes, v, g) ;
876
873
hir_visit:: walk_variant ( cx, v, g, item_id) ;
877
874
run_lints ! ( cx, check_variant_post, late_passes, v, g) ;
878
875
} )
879
876
}
880
877
881
- fn visit_ty ( & mut self , t : & hir:: Ty ) {
878
+ fn visit_ty ( & mut self , t : & ' tcx hir:: Ty ) {
882
879
run_lints ! ( self , check_ty, late_passes, t) ;
883
880
hir_visit:: walk_ty ( self , t) ;
884
881
}
@@ -887,45 +884,45 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
887
884
run_lints ! ( self , check_name, late_passes, sp, name) ;
888
885
}
889
886
890
- fn visit_mod ( & mut self , m : & hir:: Mod , s : Span , n : ast:: NodeId ) {
887
+ fn visit_mod ( & mut self , m : & ' tcx hir:: Mod , s : Span , n : ast:: NodeId ) {
891
888
run_lints ! ( self , check_mod, late_passes, m, s, n) ;
892
889
hir_visit:: walk_mod ( self , m, n) ;
893
890
run_lints ! ( self , check_mod_post, late_passes, m, s, n) ;
894
891
}
895
892
896
- fn visit_local ( & mut self , l : & hir:: Local ) {
893
+ fn visit_local ( & mut self , l : & ' tcx hir:: Local ) {
897
894
self . with_lint_attrs ( & l. attrs , |cx| {
898
895
run_lints ! ( cx, check_local, late_passes, l) ;
899
896
hir_visit:: walk_local ( cx, l) ;
900
897
} )
901
898
}
902
899
903
- fn visit_block ( & mut self , b : & hir:: Block ) {
900
+ fn visit_block ( & mut self , b : & ' tcx hir:: Block ) {
904
901
run_lints ! ( self , check_block, late_passes, b) ;
905
902
hir_visit:: walk_block ( self , b) ;
906
903
run_lints ! ( self , check_block_post, late_passes, b) ;
907
904
}
908
905
909
- fn visit_arm ( & mut self , a : & hir:: Arm ) {
906
+ fn visit_arm ( & mut self , a : & ' tcx hir:: Arm ) {
910
907
run_lints ! ( self , check_arm, late_passes, a) ;
911
908
hir_visit:: walk_arm ( self , a) ;
912
909
}
913
910
914
- fn visit_decl ( & mut self , d : & hir:: Decl ) {
911
+ fn visit_decl ( & mut self , d : & ' tcx hir:: Decl ) {
915
912
run_lints ! ( self , check_decl, late_passes, d) ;
916
913
hir_visit:: walk_decl ( self , d) ;
917
914
}
918
915
919
- fn visit_expr_post ( & mut self , e : & hir:: Expr ) {
916
+ fn visit_expr_post ( & mut self , e : & ' tcx hir:: Expr ) {
920
917
run_lints ! ( self , check_expr_post, late_passes, e) ;
921
918
}
922
919
923
- fn visit_generics ( & mut self , g : & hir:: Generics ) {
920
+ fn visit_generics ( & mut self , g : & ' tcx hir:: Generics ) {
924
921
run_lints ! ( self , check_generics, late_passes, g) ;
925
922
hir_visit:: walk_generics ( self , g) ;
926
923
}
927
924
928
- fn visit_trait_item ( & mut self , trait_item : & hir:: TraitItem ) {
925
+ fn visit_trait_item ( & mut self , trait_item : & ' tcx hir:: TraitItem ) {
929
926
self . with_lint_attrs ( & trait_item. attrs , |cx| {
930
927
run_lints ! ( cx, check_trait_item, late_passes, trait_item) ;
931
928
cx. visit_ids ( |v| hir_visit:: walk_trait_item ( v, trait_item) ) ;
@@ -934,7 +931,7 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
934
931
} ) ;
935
932
}
936
933
937
- fn visit_impl_item ( & mut self , impl_item : & hir:: ImplItem ) {
934
+ fn visit_impl_item ( & mut self , impl_item : & ' tcx hir:: ImplItem ) {
938
935
self . with_lint_attrs ( & impl_item. attrs , |cx| {
939
936
run_lints ! ( cx, check_impl_item, late_passes, impl_item) ;
940
937
cx. visit_ids ( |v| hir_visit:: walk_impl_item ( v, impl_item) ) ;
@@ -943,20 +940,20 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
943
940
} ) ;
944
941
}
945
942
946
- fn visit_lifetime ( & mut self , lt : & hir:: Lifetime ) {
943
+ fn visit_lifetime ( & mut self , lt : & ' tcx hir:: Lifetime ) {
947
944
run_lints ! ( self , check_lifetime, late_passes, lt) ;
948
945
}
949
946
950
- fn visit_lifetime_def ( & mut self , lt : & hir:: LifetimeDef ) {
947
+ fn visit_lifetime_def ( & mut self , lt : & ' tcx hir:: LifetimeDef ) {
951
948
run_lints ! ( self , check_lifetime_def, late_passes, lt) ;
952
949
}
953
950
954
- fn visit_path ( & mut self , p : & hir:: Path , id : ast:: NodeId ) {
951
+ fn visit_path ( & mut self , p : & ' tcx hir:: Path , id : ast:: NodeId ) {
955
952
run_lints ! ( self , check_path, late_passes, p, id) ;
956
953
hir_visit:: walk_path ( self , p) ;
957
954
}
958
955
959
- fn visit_path_list_item ( & mut self , prefix : & hir:: Path , item : & hir:: PathListItem ) {
956
+ fn visit_path_list_item ( & mut self , prefix : & ' tcx hir:: Path , item : & ' tcx hir:: PathListItem ) {
960
957
run_lints ! ( self , check_path_list_item, late_passes, item) ;
961
958
hir_visit:: walk_path_list_item ( self , prefix, item) ;
962
959
}
@@ -1121,7 +1118,6 @@ struct IdVisitor<'a, 'b: 'a, 'tcx: 'a+'b> {
1121
1118
1122
1119
// Output any lints that were previously added to the session.
1123
1120
impl < ' a , ' b , ' tcx , ' v > hir_visit:: Visitor < ' v > for IdVisitor < ' a , ' b , ' tcx > {
1124
-
1125
1121
fn visit_id ( & mut self , id : ast:: NodeId ) {
1126
1122
if let Some ( lints) = self . cx . sess ( ) . lints . borrow_mut ( ) . remove ( & id) {
1127
1123
debug ! ( "LateContext::visit_id: id={:?} lints={:?}" , id, lints) ;
0 commit comments