Skip to content

Commit 5b13dc7

Browse files
committed
Merge check_for_entry_fn fully into check_mod_type_wf
1 parent cd4c352 commit 5b13dc7

File tree

5 files changed

+8
-15
lines changed

5 files changed

+8
-15
lines changed

compiler/rustc_hir_analysis/src/check/entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::ops::Not;
1414
use super::check_function_signature;
1515
use crate::errors;
1616

17-
pub(crate) fn check_for_entry_fn(tcx: TyCtxt<'_>, (): ()) {
17+
pub(crate) fn check_for_entry_fn(tcx: TyCtxt<'_>) {
1818
match tcx.entry_fn(()) {
1919
Some((def_id, EntryFnType::Main { .. })) => check_main_fn_ty(tcx, def_id),
2020
Some((def_id, EntryFnType::Start)) => check_start_fn_ty(tcx, def_id),

compiler/rustc_hir_analysis/src/check/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ pub use check::check_abi;
7575

7676
use std::num::NonZeroU32;
7777

78-
use entry::check_for_entry_fn;
7978
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
8079
use rustc_errors::ErrorGuaranteed;
8180
use rustc_errors::{pluralize, struct_span_err, Diagnostic, DiagnosticBuilder};
@@ -110,7 +109,6 @@ pub fn provide(providers: &mut Providers) {
110109
wfcheck::provide(providers);
111110
*providers = Providers {
112111
adt_destructor,
113-
check_for_entry_fn,
114112
region_scope_tree,
115113
collect_return_position_impl_trait_in_trait_tys,
116114
compare_impl_const: compare_impl_item::compare_impl_const_raw,

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,11 @@ fn check_mod_type_wf(tcx: TyCtxt<'_>, module: LocalModDefId) -> Result<(), Error
19131913
let mut res = items.par_items(|item| tcx.ensure().check_well_formed(item.owner_id));
19141914
res = res.and(items.par_impl_items(|item| tcx.ensure().check_well_formed(item.owner_id)));
19151915
res = res.and(items.par_trait_items(|item| tcx.ensure().check_well_formed(item.owner_id)));
1916-
res.and(items.par_foreign_items(|item| tcx.ensure().check_well_formed(item.owner_id)))
1916+
res = res.and(items.par_foreign_items(|item| tcx.ensure().check_well_formed(item.owner_id)));
1917+
if module == LocalModDefId::CRATE_DEF_ID {
1918+
super::entry::check_for_entry_fn(tcx);
1919+
}
1920+
res
19171921
}
19181922

19191923
fn error_392(tcx: TyCtxt<'_>, span: Span, param_name: Symbol) -> DiagnosticBuilder<'_> {

compiler/rustc_hir_analysis/src/lib.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,9 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
200200
})?;
201201
}
202202

203-
let errs = tcx.sess.time("wf_checking", || {
203+
tcx.sess.time("wf_checking", || {
204204
tcx.hir().try_par_for_each_module(|module| tcx.ensure().check_mod_type_wf(module))
205-
});
206-
207-
tcx.sess.time("entry_fn_checks", || tcx.ensure().check_for_entry_fn(()));
208-
209-
// HACK: `check_for_entry_fn` wants to report its errors even if `check_mod_type_wf` has errored.
210-
errs?;
205+
})?;
211206

212207
if tcx.features().rustc_attrs {
213208
tcx.sess.track_errors(|| collect::test_opaque_hidden_types(tcx))?;

compiler/rustc_middle/src/query/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -938,10 +938,6 @@ rustc_queries! {
938938
desc { |tcx| "checking naked functions in {}", describe_as_module(key, tcx) }
939939
}
940940

941-
query check_for_entry_fn(key: ()) -> () {
942-
desc { |_tcx| "checking entry functions" }
943-
}
944-
945941
query check_mod_privacy(key: LocalModDefId) -> () {
946942
desc { |tcx| "checking privacy in {}", describe_as_module(key.to_local_def_id(), tcx) }
947943
}

0 commit comments

Comments
 (0)