Skip to content

Commit dace306

Browse files
Aatchmichaelwoerister
authored andcommitted
Inspect MIR for statics in item collection
1 parent 85b155f commit dace306

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/librustc_trans/collector.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,26 @@ fn collect_items_rec<'a, 'tcx: 'a>(scx: &SharedCrateContext<'a, 'tcx>,
341341
let ty = scx.tcx().lookup_item_type(def_id).ty;
342342
let ty = glue::get_drop_glue_type(scx.tcx(), ty);
343343
neighbors.push(TransItem::DropGlue(DropGlueKind::Ty(ty)));
344+
344345
recursion_depth_reset = None;
346+
347+
// Scan the MIR in order to find function calls, closures, and
348+
// drop-glue
349+
let mir = errors::expect(ccx.sess().diagnostic(), ccx.get_mir(def_id),
350+
|| format!("Could not find MIR for static: {:?}", def_id));
351+
352+
let empty_substs = ccx.tcx().mk_substs(Substs::empty());
353+
let mut visitor = MirNeighborCollector {
354+
ccx: ccx,
355+
mir: &mir,
356+
output: &mut neighbors,
357+
param_substs: empty_substs
358+
};
359+
360+
visitor.visit_mir(&mir);
361+
for promoted in &mir.promoted {
362+
visitor.visit_mir(promoted);
363+
}
345364
}
346365
TransItem::Fn(instance) => {
347366
// Keep track of the monomorphization recursion depth

0 commit comments

Comments
 (0)