diff options
| author | Michael Woerister <michaelwoerister@posteo> | 2018-03-13 15:40:02 +0100 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo> | 2018-03-15 12:53:20 +0100 |
| commit | b41f2278f4fadd989dbbeb174ad6a4f55de25d99 (patch) | |
| tree | c79968b7c63861ca89ebf5e4c3ccd8f79b5a740c /src | |
| parent | a4af6f089b2836530f31b6b839bde7cea8ae0b8a (diff) | |
| download | rust-b41f2278f4fadd989dbbeb174ad6a4f55de25d99.tar.gz rust-b41f2278f4fadd989dbbeb174ad6a4f55de25d99.zip | |
MonoItem collector: Cleanup start fn root collection.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/monomorphize/collector.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 7fd2ea265de..d43da5392ab 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -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 @@ 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); } } @@ -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 |
