diff --git a/compiler/rustc_hir_analysis/src/check/entry.rs b/compiler/rustc_hir_analysis/src/check/entry.rs index 81d3bf2e4519..649ac6c5aebb 100644 --- a/compiler/rustc_hir_analysis/src/check/entry.rs +++ b/compiler/rustc_hir_analysis/src/check/entry.rs @@ -14,7 +14,7 @@ use std::ops::Not; use super::check_function_signature; use crate::errors; -pub(crate) fn check_for_entry_fn(tcx: TyCtxt<'_>, (): ()) { +pub(crate) fn check_for_entry_fn(tcx: TyCtxt<'_>) { match tcx.entry_fn(()) { Some((def_id, EntryFnType::Main { .. })) => check_main_fn_ty(tcx, def_id), Some((def_id, EntryFnType::Start)) => check_start_fn_ty(tcx, def_id), diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index 14536f246936..f60d6950670d 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -75,7 +75,6 @@ pub use check::check_abi; use std::num::NonZeroU32; -use entry::check_for_entry_fn; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::ErrorGuaranteed; use rustc_errors::{pluralize, struct_span_err, Diagnostic, DiagnosticBuilder}; @@ -110,7 +109,6 @@ pub fn provide(providers: &mut Providers) { wfcheck::provide(providers); *providers = Providers { adt_destructor, - check_for_entry_fn, region_scope_tree, collect_return_position_impl_trait_in_trait_tys, compare_impl_const: compare_impl_item::compare_impl_const_raw, diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 1acfb7a91795..5f26da9c87f4 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1913,7 +1913,11 @@ fn check_mod_type_wf(tcx: TyCtxt<'_>, module: LocalModDefId) -> Result<(), Error let mut res = items.par_items(|item| tcx.ensure().check_well_formed(item.owner_id)); res = res.and(items.par_impl_items(|item| tcx.ensure().check_well_formed(item.owner_id))); res = res.and(items.par_trait_items(|item| tcx.ensure().check_well_formed(item.owner_id))); - res.and(items.par_foreign_items(|item| tcx.ensure().check_well_formed(item.owner_id))) + res = res.and(items.par_foreign_items(|item| tcx.ensure().check_well_formed(item.owner_id))); + if module == LocalModDefId::CRATE_DEF_ID { + super::entry::check_for_entry_fn(tcx); + } + res } fn error_392(tcx: TyCtxt<'_>, span: Span, param_name: Symbol) -> DiagnosticBuilder<'_> { diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 816603a9272c..b9e7500c8942 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -200,14 +200,9 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> { })?; } - let errs = tcx.sess.time("wf_checking", || { + tcx.sess.time("wf_checking", || { tcx.hir().try_par_for_each_module(|module| tcx.ensure().check_mod_type_wf(module)) - }); - - tcx.sess.time("entry_fn_checks", || tcx.ensure().check_for_entry_fn(())); - - // HACK: `check_for_entry_fn` wants to report its errors even if `check_mod_type_wf` has errored. - errs?; + })?; if tcx.features().rustc_attrs { tcx.sess.track_errors(|| collect::test_opaque_hidden_types(tcx))?; diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index cfa2705996bd..2810182c0a0d 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -938,10 +938,6 @@ rustc_queries! { desc { |tcx| "checking naked functions in {}", describe_as_module(key, tcx) } } - query check_for_entry_fn(key: ()) -> () { - desc { |_tcx| "checking entry functions" } - } - query check_mod_privacy(key: LocalModDefId) -> () { desc { |tcx| "checking privacy in {}", describe_as_module(key.to_local_def_id(), tcx) } }