Fixes compilation errors and adds proposed improvements

This commit is contained in:
Bastian Köcher
2017-12-21 12:03:01 +01:00
parent 011c9eac35
commit 99a108c036
3 changed files with 6 additions and 8 deletions

View File

@@ -195,7 +195,6 @@ use rustc::hir::map as hir_map;
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::middle::const_val::ConstVal; use rustc::middle::const_val::ConstVal;
use rustc::middle::lang_items::{ExchangeMallocFnLangItem,StartFnLangItem}; use rustc::middle::lang_items::{ExchangeMallocFnLangItem,StartFnLangItem};
use rustc::middle::trans::TransItem;
use rustc::traits; use rustc::traits;
use rustc::ty::subst::{Substs, Kind}; use rustc::ty::subst::{Substs, Kind};
use rustc::ty::{self, TypeFoldable, Ty, TyCtxt}; use rustc::ty::{self, TypeFoldable, Ty, TyCtxt};
@@ -1001,7 +1000,7 @@ impl<'b, 'a, 'v> RootCollector<'b, 'a, 'v> {
debug!("RootCollector::push_if_root: found root def_id={:?}", def_id); debug!("RootCollector::push_if_root: found root def_id={:?}", def_id);
let instance = Instance::mono(self.tcx, def_id); let instance = Instance::mono(self.tcx, def_id);
self.output.push(create_fn_trans_item(instance)); self.output.push(create_fn_mono_item(instance));
self.push_extra_entry_roots(def_id); self.push_extra_entry_roots(def_id);
} }
@@ -1041,7 +1040,7 @@ impl<'b, 'a, 'v> RootCollector<'b, 'a, 'v> {
self.tcx.mk_substs(iter::once(Kind::from(main_ret_ty))) self.tcx.mk_substs(iter::once(Kind::from(main_ret_ty)))
).unwrap(); ).unwrap();
self.output.push(create_fn_trans_item(start_instance)); self.output.push(create_fn_mono_item(start_instance));
} }
} }

View File

@@ -106,8 +106,7 @@ use monomorphize::collector::InliningMap;
use rustc::dep_graph::WorkProductId; use rustc::dep_graph::WorkProductId;
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::hir::map::DefPathData; use rustc::hir::map::DefPathData;
use rustc::middle::lang_items::StartFnLangItem; use rustc::mir::mono::{Linkage, Visibility};
use rustc::middle::trans::{Linkage, Visibility};
use rustc::ty::{self, TyCtxt, InstanceDef}; use rustc::ty::{self, TyCtxt, InstanceDef};
use rustc::ty::item_path::characteristic_def_id_of_type; use rustc::ty::item_path::characteristic_def_id_of_type;
use rustc::util::nodemap::{FxHashMap, FxHashSet}; use rustc::util::nodemap::{FxHashMap, FxHashSet};
@@ -313,11 +312,9 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
MonoItem::Fn(ref instance) => { MonoItem::Fn(ref instance) => {
let visibility = match instance.def { let visibility = match instance.def {
InstanceDef::Item(def_id) => { InstanceDef::Item(def_id) => {
let start_def_id = tcx.lang_items().require(StartFnLangItem);
// If we encounter the lang start item, we set the visibility to // If we encounter the lang start item, we set the visibility to
// default. // default.
if start_def_id == Ok(def_id) { if tcx.lang_items().start_fn() == Some(def_id) {
Visibility::Default Visibility::Default
} else if def_id.is_local() { } else if def_id.is_local() {
if tcx.is_exported_symbol(def_id) { if tcx.is_exported_symbol(def_id) {

View File

@@ -21,6 +21,8 @@ use libc;
/// a successful execution. In case of a failure, `libc::EXIT_FAILURE` is returned. /// a successful execution. In case of a failure, `libc::EXIT_FAILURE` is returned.
#[cfg_attr(not(stage0), lang = "termination")] #[cfg_attr(not(stage0), lang = "termination")]
#[unstable(feature = "termination_trait", issue = "0")] #[unstable(feature = "termination_trait", issue = "0")]
#[rustc_on_unimplemented =
"`main` can only return types that implement {Termination}, not `{Self}`"]
pub trait Termination { pub trait Termination {
/// Is called to get the representation of the value as status code. /// Is called to get the representation of the value as status code.
/// This status code is returned to the operating system. /// This status code is returned to the operating system.