@@ -19,6 +19,7 @@ use rustc_middle::middle::privacy::Level;
1919use rustc_middle:: query:: Providers ;
2020use rustc_middle:: ty:: { self , AssocTag , TyCtxt } ;
2121use rustc_middle:: { bug, span_bug} ;
22+ use rustc_session:: config:: CrateType ;
2223use rustc_session:: lint:: builtin:: DEAD_CODE ;
2324use rustc_session:: lint:: { self , LintExpectationId } ;
2425use rustc_span:: { Symbol , kw, sym} ;
@@ -813,22 +814,24 @@ fn maybe_record_as_seed<'tcx>(
813814fn create_and_seed_worklist (
814815 tcx : TyCtxt < ' _ > ,
815816) -> ( Vec < ( LocalDefId , ComesFromAllowExpect ) > , Vec < LocalDefId > ) {
816- let effective_visibilities = & tcx. effective_visibilities ( ( ) ) ;
817817 let mut unsolved_impl_item = Vec :: new ( ) ;
818- let mut worklist = effective_visibilities
819- . iter ( )
820- . filter_map ( |( & id, effective_vis) | {
821- effective_vis
822- . is_public_at_level ( Level :: Reachable )
823- . then_some ( id)
824- . map ( |id| ( id, ComesFromAllowExpect :: No ) )
825- } )
826- // Seed entry point
827- . chain (
828- tcx. entry_fn ( ( ) )
829- . and_then ( |( def_id, _) | def_id. as_local ( ) . map ( |id| ( id, ComesFromAllowExpect :: No ) ) ) ,
830- )
831- . collect :: < Vec < _ > > ( ) ;
818+ let mut worklist = Vec :: new ( ) ;
819+
820+ if let Some ( ( def_id, _) ) = tcx. entry_fn ( ( ) )
821+ && let Some ( local_def_id) = def_id. as_local ( )
822+ {
823+ worklist. push ( ( local_def_id, ComesFromAllowExpect :: No ) ) ;
824+ }
825+
826+ if !tcx. sess . opts . unstable_opts . treat_pub_as_pub_crate
827+ || !tcx. crate_types ( ) . contains ( & CrateType :: Executable )
828+ {
829+ for ( id, effective_vis) in tcx. effective_visibilities ( ( ) ) . iter ( ) {
830+ if effective_vis. is_public_at_level ( Level :: Reachable ) {
831+ worklist. push ( ( * id, ComesFromAllowExpect :: No ) ) ;
832+ }
833+ }
834+ }
832835
833836 let crate_items = tcx. hir_crate_items ( ( ) ) ;
834837 for id in crate_items. owners ( ) {
0 commit comments