Skip to content

Commit

Permalink
MonoItem collector: Cleanup start fn root collection.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Mar 15, 2018
1 parent a4af6f0 commit b41f227
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/librustc_mir/monomorphize/collector.rs
Expand Up @@ -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
Expand Down Expand Up @@ -998,8 +1000,6 @@ impl<'b, 'a, 'v> RootCollector<'b, 'a, 'v> {

let instance = Instance::mono(self.tcx, def_id);
self.output.push(create_fn_mono_item(instance));

self.push_extra_entry_roots(def_id);
}
}

Expand All @@ -1008,20 +1008,22 @@ impl<'b, 'a, 'v> RootCollector<'b, 'a, 'v> {
/// 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
Expand Down

0 comments on commit b41f227

Please sign in to comment.