Normalize EntryFnType variants to standard style
This commit is contained in:
parent
b3267dcb31
commit
442a4744e3
@ -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;
|
||||
@ -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);
|
||||
|
@ -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;
|
||||
@ -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)]
|
||||
|
@ -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;
|
||||
@ -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.
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
@ -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 => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user