@@ -1423,8 +1423,6 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
14231423 } ;
14241424
14251425 let vis = self . tcx . local_visibility ( local_def_id) ;
1426- let span = self . tcx . def_span ( self . item_def_id . to_def_id ( ) ) ;
1427- let vis_span = self . tcx . def_span ( def_id) ;
14281426 if self . in_assoc_ty && !vis. is_at_least ( self . required_visibility , self . tcx ) {
14291427 let vis_descr = match vis {
14301428 ty:: Visibility :: Public => "public" ,
@@ -1441,6 +1439,8 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
14411439 }
14421440 } ;
14431441
1442+ let span = self . tcx . def_span ( self . item_def_id . to_def_id ( ) ) ;
1443+ let vis_span = self . tcx . def_span ( def_id) ;
14441444 self . tcx . dcx ( ) . emit_err ( InPublicInterface {
14451445 span,
14461446 vis_descr,
@@ -1463,6 +1463,8 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
14631463 } else {
14641464 lint:: builtin:: PRIVATE_BOUNDS
14651465 } ;
1466+ let span = self . tcx . def_span ( self . item_def_id . to_def_id ( ) ) ;
1467+ let vis_span = self . tcx . def_span ( def_id) ;
14661468 self . tcx . emit_node_span_lint (
14671469 lint,
14681470 self . tcx . local_def_id_to_hir_id ( self . item_def_id ) ,
@@ -1594,7 +1596,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
15941596 self . effective_visibilities . effective_vis ( def_id) . copied ( )
15951597 }
15961598
1597- fn check_item ( & mut self , id : ItemId ) {
1599+ fn check_item ( & self , id : ItemId ) {
15981600 let tcx = self . tcx ;
15991601 let def_id = id. owner_id . def_id ;
16001602 let item_visibility = tcx. local_visibility ( def_id) ;
@@ -1722,7 +1724,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
17221724 }
17231725 }
17241726
1725- fn check_foreign_item ( & mut self , id : ForeignItemId ) {
1727+ fn check_foreign_item ( & self , id : ForeignItemId ) {
17261728 let tcx = self . tcx ;
17271729 let def_id = id. owner_id . def_id ;
17281730 let item_visibility = tcx. local_visibility ( def_id) ;
@@ -1854,16 +1856,12 @@ fn effective_visibilities(tcx: TyCtxt<'_>, (): ()) -> &EffectiveVisibilities {
18541856 tcx. arena . alloc ( visitor. effective_visibilities )
18551857}
18561858
1857- fn check_private_in_public ( tcx : TyCtxt < ' _ > , ( ) : ( ) ) {
1859+ fn check_private_in_public ( tcx : TyCtxt < ' _ > , module_def_id : LocalModDefId ) {
18581860 let effective_visibilities = tcx. effective_visibilities ( ( ) ) ;
18591861 // Check for private types in public interfaces.
1860- let mut checker = PrivateItemsInPublicInterfacesChecker { tcx, effective_visibilities } ;
1862+ let checker = PrivateItemsInPublicInterfacesChecker { tcx, effective_visibilities } ;
18611863
1862- let crate_items = tcx. hir_crate_items ( ( ) ) ;
1863- for id in crate_items. free_items ( ) {
1864- checker. check_item ( id) ;
1865- }
1866- for id in crate_items. foreign_items ( ) {
1867- checker. check_foreign_item ( id) ;
1868- }
1864+ let crate_items = tcx. hir_module_items ( module_def_id) ;
1865+ let _ = crate_items. par_items ( |id| Ok ( checker. check_item ( id) ) ) ;
1866+ let _ = crate_items. par_foreign_items ( |id| Ok ( checker. check_foreign_item ( id) ) ) ;
18691867}
0 commit comments