@@ -152,10 +152,11 @@ declare_lint! {
152152declare_lint_pass ! ( BoxPointers => [ BOX_POINTERS ] ) ;
153153
154154impl BoxPointers {
155- fn check_heap_type ( & self , cx : & LateContext < ' _ > , span : Span , ty : Ty < ' _ > ) {
155+ fn check_heap_type ( & self , cx : & LateContext < ' _ > , hir_id : HirId , ty : Ty < ' _ > ) {
156156 for leaf in ty. walk ( ) {
157157 if let GenericArgKind :: Type ( leaf_ty) = leaf. unpack ( ) {
158158 if leaf_ty. is_box ( ) {
159+ let span = cx. tcx . hir ( ) . span ( hir_id) ;
159160 cx. struct_span_lint ( BOX_POINTERS , span, |lint| {
160161 lint. build ( & format ! ( "type uses owned (Box type) pointers: {}" , ty) ) . emit ( )
161162 } ) ;
@@ -173,7 +174,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxPointers {
173174 | hir:: ItemKind :: Enum ( ..)
174175 | hir:: ItemKind :: Struct ( ..)
175176 | hir:: ItemKind :: Union ( ..) => {
176- self . check_heap_type ( cx, it. span , cx. tcx . type_of ( it. def_id ) )
177+ self . check_heap_type ( cx, it. hir_id ( ) , cx. tcx . type_of ( it. def_id ) )
177178 }
178179 _ => ( ) ,
179180 }
@@ -183,8 +184,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxPointers {
183184 hir:: ItemKind :: Struct ( ref struct_def, _) | hir:: ItemKind :: Union ( ref struct_def, _) => {
184185 for struct_field in struct_def. fields ( ) {
185186 let def_id = cx. tcx . hir ( ) . local_def_id ( struct_field. hir_id ) ;
186- let span = cx. tcx . hir ( ) . span ( struct_field. hir_id ) ;
187- self . check_heap_type ( cx, span, cx. tcx . type_of ( def_id) ) ;
187+ self . check_heap_type ( cx, struct_field. hir_id , cx. tcx . type_of ( def_id) ) ;
188188 }
189189 }
190190 _ => ( ) ,
@@ -193,7 +193,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxPointers {
193193
194194 fn check_expr ( & mut self , cx : & LateContext < ' _ > , e : & hir:: Expr < ' _ > ) {
195195 let ty = cx. typeck_results ( ) . node_type ( e. hir_id ) ;
196- self . check_heap_type ( cx, e. span , ty) ;
196+ self . check_heap_type ( cx, e. hir_id , ty) ;
197197 }
198198}
199199
@@ -511,7 +511,6 @@ impl MissingDoc {
511511 & self ,
512512 cx : & LateContext < ' _ > ,
513513 id : hir:: HirId ,
514- sp : Span ,
515514 article : & ' static str ,
516515 desc : & ' static str ,
517516 ) {
@@ -538,6 +537,7 @@ impl MissingDoc {
538537 let attrs = cx. tcx . hir ( ) . attrs ( id) ;
539538 let has_doc = attrs. iter ( ) . any ( |a| has_doc ( cx. sess ( ) , a) ) ;
540539 if !has_doc {
540+ let sp = cx. tcx . hir ( ) . span ( id) ;
541541 cx. struct_span_lint (
542542 MISSING_DOCS ,
543543 cx. tcx . sess . source_map ( ) . guess_head_span ( sp) ,
@@ -567,8 +567,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
567567 }
568568
569569 fn check_crate ( & mut self , cx : & LateContext < ' _ > , krate : & hir:: Crate < ' _ > ) {
570- let span = cx. tcx . hir ( ) . span ( hir:: CRATE_HIR_ID ) ;
571- self . check_missing_docs_attrs ( cx, hir:: CRATE_HIR_ID , span, "the" , "crate" ) ;
570+ self . check_missing_docs_attrs ( cx, hir:: CRATE_HIR_ID , "the" , "crate" ) ;
572571
573572 for macro_def in krate. exported_macros {
574573 let attrs = cx. tcx . hir ( ) . attrs ( macro_def. hir_id ( ) ) ;
@@ -627,7 +626,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
627626
628627 let ( article, desc) = cx. tcx . article_and_description ( it. def_id . to_def_id ( ) ) ;
629628
630- self . check_missing_docs_attrs ( cx, it. hir_id ( ) , it . span , article, desc) ;
629+ self . check_missing_docs_attrs ( cx, it. hir_id ( ) , article, desc) ;
631630 }
632631
633632 fn check_trait_item ( & mut self , cx : & LateContext < ' _ > , trait_item : & hir:: TraitItem < ' _ > ) {
@@ -637,7 +636,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
637636
638637 let ( article, desc) = cx. tcx . article_and_description ( trait_item. def_id . to_def_id ( ) ) ;
639638
640- self . check_missing_docs_attrs ( cx, trait_item. hir_id ( ) , trait_item . span , article, desc) ;
639+ self . check_missing_docs_attrs ( cx, trait_item. hir_id ( ) , article, desc) ;
641640 }
642641
643642 fn check_impl_item ( & mut self , cx : & LateContext < ' _ > , impl_item : & hir:: ImplItem < ' _ > ) {
@@ -647,24 +646,22 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
647646 }
648647
649648 let ( article, desc) = cx. tcx . article_and_description ( impl_item. def_id . to_def_id ( ) ) ;
650- self . check_missing_docs_attrs ( cx, impl_item. hir_id ( ) , impl_item . span , article, desc) ;
649+ self . check_missing_docs_attrs ( cx, impl_item. hir_id ( ) , article, desc) ;
651650 }
652651
653652 fn check_foreign_item ( & mut self , cx : & LateContext < ' _ > , foreign_item : & hir:: ForeignItem < ' _ > ) {
654653 let ( article, desc) = cx. tcx . article_and_description ( foreign_item. def_id . to_def_id ( ) ) ;
655- self . check_missing_docs_attrs ( cx, foreign_item. hir_id ( ) , foreign_item . span , article, desc) ;
654+ self . check_missing_docs_attrs ( cx, foreign_item. hir_id ( ) , article, desc) ;
656655 }
657656
658657 fn check_struct_field ( & mut self , cx : & LateContext < ' _ > , sf : & hir:: StructField < ' _ > ) {
659658 if !sf. is_positional ( ) {
660- let span = cx. tcx . hir ( ) . span ( sf. hir_id ) ;
661- self . check_missing_docs_attrs ( cx, sf. hir_id , span, "a" , "struct field" )
659+ self . check_missing_docs_attrs ( cx, sf. hir_id , "a" , "struct field" )
662660 }
663661 }
664662
665663 fn check_variant ( & mut self , cx : & LateContext < ' _ > , v : & hir:: Variant < ' _ > ) {
666- let span = cx. tcx . hir ( ) . span ( v. id ) ;
667- self . check_missing_docs_attrs ( cx, v. id , span, "a" , "variant" ) ;
664+ self . check_missing_docs_attrs ( cx, v. id , "a" , "variant" ) ;
668665 }
669666}
670667
@@ -1299,12 +1296,12 @@ impl UnreachablePub {
12991296 what : & str ,
13001297 id : hir:: HirId ,
13011298 vis : & hir:: Visibility < ' _ > ,
1302- span : Span ,
13031299 exportable : bool ,
13041300 ) {
13051301 let mut applicability = Applicability :: MachineApplicable ;
13061302 match vis. node {
13071303 hir:: VisibilityKind :: Public if !cx. access_levels . is_reachable ( id) => {
1304+ let span = cx. tcx . hir ( ) . span ( id) ;
13081305 if span. from_expansion ( ) {
13091306 applicability = Applicability :: MaybeIncorrect ;
13101307 }
@@ -1337,27 +1334,19 @@ impl UnreachablePub {
13371334
13381335impl < ' tcx > LateLintPass < ' tcx > for UnreachablePub {
13391336 fn check_item ( & mut self , cx : & LateContext < ' _ > , item : & hir:: Item < ' _ > ) {
1340- self . perform_lint ( cx, "item" , item. hir_id ( ) , & item. vis , item . span , true ) ;
1337+ self . perform_lint ( cx, "item" , item. hir_id ( ) , & item. vis , true ) ;
13411338 }
13421339
13431340 fn check_foreign_item ( & mut self , cx : & LateContext < ' _ > , foreign_item : & hir:: ForeignItem < ' tcx > ) {
1344- self . perform_lint (
1345- cx,
1346- "item" ,
1347- foreign_item. hir_id ( ) ,
1348- & foreign_item. vis ,
1349- foreign_item. span ,
1350- true ,
1351- ) ;
1341+ self . perform_lint ( cx, "item" , foreign_item. hir_id ( ) , & foreign_item. vis , true ) ;
13521342 }
13531343
13541344 fn check_struct_field ( & mut self , cx : & LateContext < ' _ > , field : & hir:: StructField < ' _ > ) {
1355- let span = cx. tcx . hir ( ) . span ( field. hir_id ) ;
1356- self . perform_lint ( cx, "field" , field. hir_id , & field. vis , span, false ) ;
1345+ self . perform_lint ( cx, "field" , field. hir_id , & field. vis , false ) ;
13571346 }
13581347
13591348 fn check_impl_item ( & mut self , cx : & LateContext < ' _ > , impl_item : & hir:: ImplItem < ' _ > ) {
1360- self . perform_lint ( cx, "item" , impl_item. hir_id ( ) , & impl_item. vis , impl_item . span , false ) ;
1349+ self . perform_lint ( cx, "item" , impl_item. hir_id ( ) , & impl_item. vis , false ) ;
13611350 }
13621351}
13631352
0 commit comments