Skip to content

Commit

Permalink
Normalize EntryFnType variants to standard style
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Aug 4, 2018
1 parent b3267dc commit 442a474
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
7 changes: 4 additions & 3 deletions src/librustc/middle/entry.rs
Expand Up @@ -12,6 +12,7 @@
use hir::map as hir_map;
use hir::def_id::{CRATE_DEF_INDEX};
use session::{config, Session};
use session::config::EntryFnType;
use syntax::ast::NodeId;
use syntax::attr;
use syntax::entry::EntryPointType;
Expand Down Expand Up @@ -155,11 +156,11 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) {

fn configure_main(this: &mut EntryContext, crate_name: &str) {
if let Some((node_id, span)) = this.start_fn {
this.session.entry_fn.set(Some((node_id, span, config::EntryStart)));
this.session.entry_fn.set(Some((node_id, span, EntryFnType::Start)));
} else if let Some((node_id, span)) = this.attr_main_fn {
this.session.entry_fn.set(Some((node_id, span, config::EntryMain)));
this.session.entry_fn.set(Some((node_id, span, EntryFnType::Main)));
} else if let Some((node_id, span)) = this.main_fn {
this.session.entry_fn.set(Some((node_id, span, config::EntryMain)));
this.session.entry_fn.set(Some((node_id, span, EntryFnType::Main)));
} else {
// No main function
this.session.entry_fn.set(None);
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/session/config.rs
Expand Up @@ -11,7 +11,6 @@
//! Contains infrastructure for configuring the compiler, including parsing
//! command line options.

pub use self::EntryFnType::*;
pub use self::DebugInfoLevel::*;

use std::str::FromStr;
Expand Down Expand Up @@ -662,8 +661,8 @@ impl Options {
// functions
#[derive(Copy, Clone, PartialEq)]
pub enum EntryFnType {
EntryMain,
EntryStart,
Main,
Start,
}

#[derive(Copy, PartialEq, PartialOrd, Clone, Ord, Eq, Hash, Debug)]
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_llvm/base.rs
Expand Up @@ -46,7 +46,7 @@ use rustc::middle::cstore::{self, LinkMeta, LinkagePreference};
use rustc::middle::exported_symbols;
use rustc::util::common::{time, print_time_passes_entry};
use rustc::util::profiling::ProfileCategory;
use rustc::session::config::{self, NoDebugInfo};
use rustc::session::config::{self, NoDebugInfo, EntryFnType};
use rustc::session::Session;
use rustc_incremental;
use allocator;
Expand Down Expand Up @@ -560,8 +560,8 @@ fn maybe_create_entry_wrapper(cx: &CodegenCx) {

let et = cx.sess().entry_fn.get().map(|e| e.2);
match et {
Some(config::EntryMain) => create_entry_fn(cx, span, main_llfn, main_def_id, true),
Some(config::EntryStart) => create_entry_fn(cx, span, main_llfn, main_def_id, false),
Some(EntryFnType::Main) => create_entry_fn(cx, span, main_llfn, main_def_id, true),
Some(EntryFnType::Start) => create_entry_fn(cx, span, main_llfn, main_def_id, false),
None => {} // Do nothing.
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/monomorphize/collector.rs
Expand Up @@ -1047,7 +1047,7 @@ impl<'b, 'a, 'v> RootCollector<'b, 'a, 'v> {
/// the return type of `main`. This is not needed when
/// the user writes their own `start` manually.
fn push_extra_entry_roots(&mut self) {
if self.tcx.sess.entry_fn.get().map(|e| e.2) != Some(config::EntryMain) {
if self.tcx.sess.entry_fn.get().map(|e| e.2) != Some(config::EntryFnType::Main) {
return
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/mod.rs
Expand Up @@ -1111,7 +1111,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
if let Some((id, _, entry_type)) = *fcx.tcx.sess.entry_fn.borrow() {
if id == fn_id {
match entry_type {
config::EntryMain => {
config::EntryFnType::Main => {
let substs = fcx.tcx.mk_substs_trait(declared_ret_ty, &[]);
let trait_ref = ty::TraitRef::new(term_id, substs);
let return_ty_span = decl.output.span();
Expand All @@ -1122,7 +1122,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
traits::Obligation::new(
cause, param_env, trait_ref.to_predicate()));
},
config::EntryStart => {},
config::EntryFnType::Start => {},
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/lib.rs
Expand Up @@ -318,8 +318,8 @@ fn check_start_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
fn check_for_entry_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
if let Some((id, sp, entry_type)) = *tcx.sess.entry_fn.borrow() {
match entry_type {
config::EntryMain => check_main_fn_ty(tcx, id, sp),
config::EntryStart => check_start_fn_ty(tcx, id, sp),
config::EntryFnType::Main => check_main_fn_ty(tcx, id, sp),
config::EntryFnType::Start => check_start_fn_ty(tcx, id, sp),
}
}
}
Expand Down

0 comments on commit 442a474

Please sign in to comment.