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