diff options
| author | James Miller <james@aatch.net> | 2016-05-10 09:00:31 +1200 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo.net> | 2016-05-11 13:58:52 -0400 |
| commit | dace30659f286206c633fcaaf45d9aa02386a3ac (patch) | |
| tree | ab63cb5e4bdacf84cd4a92a9f59a3dd63b31a6fa | |
| parent | 85b155f6f1941be159b5a2790b5396fece101f64 (diff) | |
| download | rust-dace30659f286206c633fcaaf45d9aa02386a3ac.tar.gz rust-dace30659f286206c633fcaaf45d9aa02386a3ac.zip | |
Inspect MIR for statics in item collection
| -rw-r--r-- | src/librustc_trans/collector.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/librustc_trans/collector.rs b/src/librustc_trans/collector.rs index 0614c29aaed..f23f931d753 100644 --- a/src/librustc_trans/collector.rs +++ b/src/librustc_trans/collector.rs @@ -341,7 +341,26 @@ fn collect_items_rec<'a, 'tcx: 'a>(scx: &SharedCrateContext<'a, 'tcx>, let ty = scx.tcx().lookup_item_type(def_id).ty; let ty = glue::get_drop_glue_type(scx.tcx(), ty); neighbors.push(TransItem::DropGlue(DropGlueKind::Ty(ty))); + recursion_depth_reset = None; + + // Scan the MIR in order to find function calls, closures, and + // drop-glue + let mir = errors::expect(ccx.sess().diagnostic(), ccx.get_mir(def_id), + || format!("Could not find MIR for static: {:?}", def_id)); + + let empty_substs = ccx.tcx().mk_substs(Substs::empty()); + let mut visitor = MirNeighborCollector { + ccx: ccx, + mir: &mir, + output: &mut neighbors, + param_substs: empty_substs + }; + + visitor.visit_mir(&mir); + for promoted in &mir.promoted { + visitor.visit_mir(promoted); + } } TransItem::Fn(instance) => { // Keep track of the monomorphization recursion depth |
