@@ -1422,8 +1422,6 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
1422
1422
} ;
1423
1423
1424
1424
let vis = self . tcx . local_visibility ( local_def_id) ;
1425
- let span = self . tcx . def_span ( self . item_def_id . to_def_id ( ) ) ;
1426
- let vis_span = self . tcx . def_span ( def_id) ;
1427
1425
if self . in_assoc_ty && !vis. is_at_least ( self . required_visibility , self . tcx ) {
1428
1426
let vis_descr = match vis {
1429
1427
ty:: Visibility :: Public => "public" ,
@@ -1440,6 +1438,8 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
1440
1438
}
1441
1439
} ;
1442
1440
1441
+ let span = self . tcx . def_span ( self . item_def_id . to_def_id ( ) ) ;
1442
+ let vis_span = self . tcx . def_span ( def_id) ;
1443
1443
self . tcx . dcx ( ) . emit_err ( InPublicInterface {
1444
1444
span,
1445
1445
vis_descr,
@@ -1462,6 +1462,8 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
1462
1462
} else {
1463
1463
lint:: builtin:: PRIVATE_BOUNDS
1464
1464
} ;
1465
+ let span = self . tcx . def_span ( self . item_def_id . to_def_id ( ) ) ;
1466
+ let vis_span = self . tcx . def_span ( def_id) ;
1465
1467
self . tcx . emit_node_span_lint (
1466
1468
lint,
1467
1469
self . tcx . local_def_id_to_hir_id ( self . item_def_id ) ,
@@ -1593,7 +1595,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
1593
1595
self . effective_visibilities . effective_vis ( def_id) . copied ( )
1594
1596
}
1595
1597
1596
- fn check_item ( & mut self , id : ItemId ) {
1598
+ fn check_item ( & self , id : ItemId ) {
1597
1599
let tcx = self . tcx ;
1598
1600
let def_id = id. owner_id . def_id ;
1599
1601
let item_visibility = tcx. local_visibility ( def_id) ;
@@ -1721,7 +1723,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> {
1721
1723
}
1722
1724
}
1723
1725
1724
- fn check_foreign_item ( & mut self , id : ForeignItemId ) {
1726
+ fn check_foreign_item ( & self , id : ForeignItemId ) {
1725
1727
let tcx = self . tcx ;
1726
1728
let def_id = id. owner_id . def_id ;
1727
1729
let item_visibility = tcx. local_visibility ( def_id) ;
@@ -1853,16 +1855,12 @@ fn effective_visibilities(tcx: TyCtxt<'_>, (): ()) -> &EffectiveVisibilities {
1853
1855
tcx. arena . alloc ( visitor. effective_visibilities )
1854
1856
}
1855
1857
1856
- fn check_private_in_public ( tcx : TyCtxt < ' _ > , ( ) : ( ) ) {
1858
+ fn check_private_in_public ( tcx : TyCtxt < ' _ > , module_def_id : LocalModDefId ) {
1857
1859
let effective_visibilities = tcx. effective_visibilities ( ( ) ) ;
1858
1860
// Check for private types in public interfaces.
1859
- let mut checker = PrivateItemsInPublicInterfacesChecker { tcx, effective_visibilities } ;
1861
+ let checker = PrivateItemsInPublicInterfacesChecker { tcx, effective_visibilities } ;
1860
1862
1861
- let crate_items = tcx. hir_crate_items ( ( ) ) ;
1862
- for id in crate_items. free_items ( ) {
1863
- checker. check_item ( id) ;
1864
- }
1865
- for id in crate_items. foreign_items ( ) {
1866
- checker. check_foreign_item ( id) ;
1867
- }
1863
+ let crate_items = tcx. hir_module_items ( module_def_id) ;
1864
+ let _ = crate_items. par_items ( |id| Ok ( checker. check_item ( id) ) ) ;
1865
+ let _ = crate_items. par_foreign_items ( |id| Ok ( checker. check_foreign_item ( id) ) ) ;
1868
1866
}
0 commit comments