Skip to content

Commit

Permalink
Inspect MIR for statics in item collection
Browse files Browse the repository at this point in the history
  • Loading branch information
Aatch authored and michaelwoerister committed May 11, 2016
1 parent 85b155f commit dace306
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/librustc_trans/collector.rs
Expand Up @@ -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
Expand Down

0 comments on commit dace306

Please sign in to comment.