Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 829a9d3

Browse files
committed
Use () for entry_fn.
1 parent 601453a commit 829a9d3

File tree

13 files changed

+19
-27
lines changed

13 files changed

+19
-27
lines changed

compiler/rustc_codegen_cranelift/src/main_shim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub(crate) fn maybe_create_entry_wrapper(
1515
unwind_context: &mut UnwindContext,
1616
is_jit: bool,
1717
) {
18-
let (main_def_id, is_main_fn) = match tcx.entry_fn(LOCAL_CRATE) {
18+
let (main_def_id, is_main_fn) = match tcx.entry_fn(()) {
1919
Some((def_id, entry_ty)) => (
2020
def_id,
2121
match entry_ty {

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, Variab
2323
use rustc_codegen_ssa::traits::*;
2424
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
2525
use rustc_data_structures::sync::Lrc;
26-
use rustc_hir::def_id::{DefId, DefIdMap, LOCAL_CRATE};
26+
use rustc_hir::def_id::{DefId, DefIdMap};
2727
use rustc_index::vec::IndexVec;
2828
use rustc_middle::mir;
2929
use rustc_middle::ty::layout::HasTyCtxt;
@@ -343,7 +343,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
343343
if self.sess().opts.optimize != config::OptLevel::No {
344344
spflags |= DISPFlags::SPFlagOptimized;
345345
}
346-
if let Some((id, _)) = self.tcx.entry_fn(LOCAL_CRATE) {
346+
if let Some((id, _)) = self.tcx.entry_fn(()) {
347347
if id == def_id {
348348
spflags |= DISPFlags::SPFlagMainSubprogram;
349349
}

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ fn exported_symbols_provider_local(
174174
.map(|(&def_id, &level)| (ExportedSymbol::NonGeneric(def_id), level))
175175
.collect();
176176

177-
if tcx.entry_fn(LOCAL_CRATE).is_some() {
177+
if tcx.entry_fn(()).is_some() {
178178
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, "main"));
179179

180180
symbols.push((exported_symbol, SymbolExportLevel::C));

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ pub fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
347347
pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
348348
cx: &'a Bx::CodegenCx,
349349
) -> Option<Bx::Function> {
350-
let main_def_id = cx.tcx().entry_fn(LOCAL_CRATE).map(|(def_id, _)| def_id)?;
350+
let (main_def_id, entry_type) = cx.tcx().entry_fn(())?;
351351
let main_is_local = main_def_id.is_local();
352352
let instance = Instance::mono(cx.tcx(), main_def_id);
353353

@@ -364,10 +364,9 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
364364

365365
let main_llfn = cx.get_fn_addr(instance);
366366

367-
return cx.tcx().entry_fn(LOCAL_CRATE).map(|(_, et)| {
368-
let use_start_lang_item = EntryFnType::Start != et;
369-
create_entry_fn::<Bx>(cx, main_llfn, main_def_id, use_start_lang_item)
370-
});
367+
let use_start_lang_item = EntryFnType::Start != entry_type;
368+
let entry_fn = create_entry_fn::<Bx>(cx, main_llfn, main_def_id, use_start_lang_item);
369+
return Some(entry_fn);
371370

372371
fn create_entry_fn<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
373372
cx: &'a Bx::CodegenCx,

compiler/rustc_interface/src/passes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
820820
sess.time("misc_checking_1", || {
821821
parallel!(
822822
{
823-
entry_point = sess
824-
.time("looking_for_entry_point", || rustc_passes::entry::find_entry_point(tcx));
823+
entry_point = sess.time("looking_for_entry_point", || tcx.entry_fn(()));
825824

826825
sess.time("looking_for_plugin_registrar", || {
827826
plugin::build::find_plugin_registrar(tcx)

compiler/rustc_interface/src/queries.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl<'tcx> Queries<'tcx> {
302302
/// to write UI tests that actually test that compilation succeeds without reporting
303303
/// an error.
304304
fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) {
305-
let def_id = match tcx.entry_fn(LOCAL_CRATE) {
305+
let def_id = match tcx.entry_fn(()) {
306306
Some((def_id, _)) => def_id,
307307
_ => return,
308308
};

compiler/rustc_middle/src/mir/mono.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<'tcx> MonoItem<'tcx> {
8888

8989
match *self {
9090
MonoItem::Fn(ref instance) => {
91-
let entry_def_id = tcx.entry_fn(LOCAL_CRATE).map(|(id, _)| id);
91+
let entry_def_id = tcx.entry_fn(()).map(|(id, _)| id);
9292
// If this function isn't inlined or otherwise has an extern
9393
// indicator, then we'll be creating a globally shared version.
9494
if tcx.codegen_fn_attrs(instance.def_id()).contains_extern_indicator()

compiler/rustc_middle/src/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ rustc_queries! {
12011201

12021202
/// Identifies the entry-point (e.g., the `main` function) for a given
12031203
/// crate, returning `None` if there is no entry point (such as for library crates).
1204-
query entry_fn(_: CrateNum) -> Option<(DefId, EntryFnType)> {
1204+
query entry_fn(_: ()) -> Option<(DefId, EntryFnType)> {
12051205
desc { "looking up the entry function of a crate" }
12061206
}
12071207
query plugin_registrar_fn(_: CrateNum) -> Option<DefId> {

compiler/rustc_mir/src/monomorphize/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ fn collect_roots(tcx: TyCtxt<'_>, mode: MonoItemCollectionMode) -> Vec<MonoItem<
322322
let mut roots = Vec::new();
323323

324324
{
325-
let entry_fn = tcx.entry_fn(LOCAL_CRATE);
325+
let entry_fn = tcx.entry_fn(());
326326

327327
debug!("collect_roots: entry_fn = {:?}", entry_fn);
328328

compiler/rustc_passes/src/dead.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ fn create_and_seed_worklist<'tcx>(
472472
)
473473
.chain(
474474
// Seed entry point
475-
tcx.entry_fn(LOCAL_CRATE).and_then(|(def_id, _)| {
475+
tcx.entry_fn(()).and_then(|(def_id, _)| {
476476
def_id.as_local().map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id))
477477
}),
478478
)

0 commit comments

Comments
 (0)