@@ -792,21 +792,15 @@ impl<'a> LintContext for EarlyContext<'a> {
792792 }
793793}
794794
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 > {
796796 /// Because lints are scoped lexically, we want to walk nested
797797 /// items in the context of the outer item, so enable
798798 /// 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 )
802801 }
803802
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 ) {
810804 self . with_lint_attrs ( & it. attrs , |cx| {
811805 run_lints ! ( cx, check_item, late_passes, it) ;
812806 cx. visit_ids ( |v| v. visit_item ( it) ) ;
@@ -815,27 +809,27 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
815809 } )
816810 }
817811
818- fn visit_foreign_item ( & mut self , it : & hir:: ForeignItem ) {
812+ fn visit_foreign_item ( & mut self , it : & ' tcx hir:: ForeignItem ) {
819813 self . with_lint_attrs ( & it. attrs , |cx| {
820814 run_lints ! ( cx, check_foreign_item, late_passes, it) ;
821815 hir_visit:: walk_foreign_item ( cx, it) ;
822816 run_lints ! ( cx, check_foreign_item_post, late_passes, it) ;
823817 } )
824818 }
825819
826- fn visit_pat ( & mut self , p : & hir:: Pat ) {
820+ fn visit_pat ( & mut self , p : & ' tcx hir:: Pat ) {
827821 run_lints ! ( self , check_pat, late_passes, p) ;
828822 hir_visit:: walk_pat ( self , p) ;
829823 }
830824
831- fn visit_expr ( & mut self , e : & hir:: Expr ) {
825+ fn visit_expr ( & mut self , e : & ' tcx hir:: Expr ) {
832826 self . with_lint_attrs ( & e. attrs , |cx| {
833827 run_lints ! ( cx, check_expr, late_passes, e) ;
834828 hir_visit:: walk_expr ( cx, e) ;
835829 } )
836830 }
837831
838- fn visit_stmt ( & mut self , s : & hir:: Stmt ) {
832+ fn visit_stmt ( & mut self , s : & ' tcx hir:: Stmt ) {
839833 // statement attributes are actually just attributes on one of
840834 // - item
841835 // - local
@@ -845,40 +839,43 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
845839 hir_visit:: walk_stmt ( self , s) ;
846840 }
847841
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 ) {
850844 run_lints ! ( self , check_fn, late_passes, fk, decl, body, span, id) ;
851845 hir_visit:: walk_fn ( self , fk, decl, body, span, id) ;
852846 run_lints ! ( self , check_fn_post, late_passes, fk, decl, body, span, id) ;
853847 }
854848
855849 fn visit_variant_data ( & mut self ,
856- s : & hir:: VariantData ,
850+ s : & ' tcx hir:: VariantData ,
857851 name : ast:: Name ,
858- g : & hir:: Generics ,
852+ g : & ' tcx hir:: Generics ,
859853 item_id : ast:: NodeId ,
860854 _: Span ) {
861855 run_lints ! ( self , check_struct_def, late_passes, s, name, g, item_id) ;
862856 hir_visit:: walk_struct_def ( self , s) ;
863857 run_lints ! ( self , check_struct_def_post, late_passes, s, name, g, item_id) ;
864858 }
865859
866- fn visit_struct_field ( & mut self , s : & hir:: StructField ) {
860+ fn visit_struct_field ( & mut self , s : & ' tcx hir:: StructField ) {
867861 self . with_lint_attrs ( & s. attrs , |cx| {
868862 run_lints ! ( cx, check_struct_field, late_passes, s) ;
869863 hir_visit:: walk_struct_field ( cx, s) ;
870864 } )
871865 }
872866
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 ) {
874871 self . with_lint_attrs ( & v. node . attrs , |cx| {
875872 run_lints ! ( cx, check_variant, late_passes, v, g) ;
876873 hir_visit:: walk_variant ( cx, v, g, item_id) ;
877874 run_lints ! ( cx, check_variant_post, late_passes, v, g) ;
878875 } )
879876 }
880877
881- fn visit_ty ( & mut self , t : & hir:: Ty ) {
878+ fn visit_ty ( & mut self , t : & ' tcx hir:: Ty ) {
882879 run_lints ! ( self , check_ty, late_passes, t) ;
883880 hir_visit:: walk_ty ( self , t) ;
884881 }
@@ -887,45 +884,45 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
887884 run_lints ! ( self , check_name, late_passes, sp, name) ;
888885 }
889886
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 ) {
891888 run_lints ! ( self , check_mod, late_passes, m, s, n) ;
892889 hir_visit:: walk_mod ( self , m, n) ;
893890 run_lints ! ( self , check_mod_post, late_passes, m, s, n) ;
894891 }
895892
896- fn visit_local ( & mut self , l : & hir:: Local ) {
893+ fn visit_local ( & mut self , l : & ' tcx hir:: Local ) {
897894 self . with_lint_attrs ( & l. attrs , |cx| {
898895 run_lints ! ( cx, check_local, late_passes, l) ;
899896 hir_visit:: walk_local ( cx, l) ;
900897 } )
901898 }
902899
903- fn visit_block ( & mut self , b : & hir:: Block ) {
900+ fn visit_block ( & mut self , b : & ' tcx hir:: Block ) {
904901 run_lints ! ( self , check_block, late_passes, b) ;
905902 hir_visit:: walk_block ( self , b) ;
906903 run_lints ! ( self , check_block_post, late_passes, b) ;
907904 }
908905
909- fn visit_arm ( & mut self , a : & hir:: Arm ) {
906+ fn visit_arm ( & mut self , a : & ' tcx hir:: Arm ) {
910907 run_lints ! ( self , check_arm, late_passes, a) ;
911908 hir_visit:: walk_arm ( self , a) ;
912909 }
913910
914- fn visit_decl ( & mut self , d : & hir:: Decl ) {
911+ fn visit_decl ( & mut self , d : & ' tcx hir:: Decl ) {
915912 run_lints ! ( self , check_decl, late_passes, d) ;
916913 hir_visit:: walk_decl ( self , d) ;
917914 }
918915
919- fn visit_expr_post ( & mut self , e : & hir:: Expr ) {
916+ fn visit_expr_post ( & mut self , e : & ' tcx hir:: Expr ) {
920917 run_lints ! ( self , check_expr_post, late_passes, e) ;
921918 }
922919
923- fn visit_generics ( & mut self , g : & hir:: Generics ) {
920+ fn visit_generics ( & mut self , g : & ' tcx hir:: Generics ) {
924921 run_lints ! ( self , check_generics, late_passes, g) ;
925922 hir_visit:: walk_generics ( self , g) ;
926923 }
927924
928- fn visit_trait_item ( & mut self , trait_item : & hir:: TraitItem ) {
925+ fn visit_trait_item ( & mut self , trait_item : & ' tcx hir:: TraitItem ) {
929926 self . with_lint_attrs ( & trait_item. attrs , |cx| {
930927 run_lints ! ( cx, check_trait_item, late_passes, trait_item) ;
931928 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> {
934931 } ) ;
935932 }
936933
937- fn visit_impl_item ( & mut self , impl_item : & hir:: ImplItem ) {
934+ fn visit_impl_item ( & mut self , impl_item : & ' tcx hir:: ImplItem ) {
938935 self . with_lint_attrs ( & impl_item. attrs , |cx| {
939936 run_lints ! ( cx, check_impl_item, late_passes, impl_item) ;
940937 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> {
943940 } ) ;
944941 }
945942
946- fn visit_lifetime ( & mut self , lt : & hir:: Lifetime ) {
943+ fn visit_lifetime ( & mut self , lt : & ' tcx hir:: Lifetime ) {
947944 run_lints ! ( self , check_lifetime, late_passes, lt) ;
948945 }
949946
950- fn visit_lifetime_def ( & mut self , lt : & hir:: LifetimeDef ) {
947+ fn visit_lifetime_def ( & mut self , lt : & ' tcx hir:: LifetimeDef ) {
951948 run_lints ! ( self , check_lifetime_def, late_passes, lt) ;
952949 }
953950
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 ) {
955952 run_lints ! ( self , check_path, late_passes, p, id) ;
956953 hir_visit:: walk_path ( self , p) ;
957954 }
958955
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 ) {
960957 run_lints ! ( self , check_path_list_item, late_passes, item) ;
961958 hir_visit:: walk_path_list_item ( self , prefix, item) ;
962959 }
@@ -1121,7 +1118,6 @@ struct IdVisitor<'a, 'b: 'a, 'tcx: 'a+'b> {
11211118
11221119// Output any lints that were previously added to the session.
11231120impl < ' a , ' b , ' tcx , ' v > hir_visit:: Visitor < ' v > for IdVisitor < ' a , ' b , ' tcx > {
1124-
11251121 fn visit_id ( & mut self , id : ast:: NodeId ) {
11261122 if let Some ( lints) = self . cx . sess ( ) . lints . borrow_mut ( ) . remove ( & id) {
11271123 debug ! ( "LateContext::visit_id: id={:?} lints={:?}" , id, lints) ;
0 commit comments