提交 b41f2278 编写于 作者: M Michael Woerister

MonoItem collector: Cleanup start fn root collection.

上级 a4af6f08
......@@ -341,6 +341,8 @@ fn collect_roots<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
};
tcx.hir.krate().visit_all_item_likes(&mut visitor);
visitor.push_extra_entry_roots();
}
// We can only translate items that are instantiable - items all of
......@@ -998,8 +1000,6 @@ fn push_if_root(&mut self, def_id: DefId) {
let instance = Instance::mono(self.tcx, def_id);
self.output.push(create_fn_mono_item(instance));
self.push_extra_entry_roots(def_id);
}
}
......@@ -1008,20 +1008,22 @@ fn push_if_root(&mut self, def_id: DefId) {
/// monomorphized copy of the start lang item based on
/// the return type of `main`. This is not needed when
/// the user writes their own `start` manually.
fn push_extra_entry_roots(&mut self, def_id: DefId) {
if self.entry_fn != Some(def_id) {
return;
}
fn push_extra_entry_roots(&mut self) {
if self.tcx.sess.entry_type.get() != Some(config::EntryMain) {
return;
return
}
let main_def_id = if let Some(def_id) = self.entry_fn {
def_id
} else {
return
};
let start_def_id = match self.tcx.lang_items().require(StartFnLangItem) {
Ok(s) => s,
Err(err) => self.tcx.sess.fatal(&err),
};
let main_ret_ty = self.tcx.fn_sig(def_id).output();
let main_ret_ty = self.tcx.fn_sig(main_def_id).output();
// Given that `main()` has no arguments,
// then its return type cannot have
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册