Skip to content

Commit

Permalink
Also store MIR of closures in crate metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Jan 8, 2016
1 parent 64a8ffe commit c8a547a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/librustc_metadata/encoder.rs
Expand Up @@ -806,18 +806,18 @@ fn encode_inlined_item(ecx: &EncodeContext,
let eii: &mut EncodeInlinedItem = &mut *eii;
eii(ecx, rbml_w, ii);

encode_mir(ecx, rbml_w, ii);
}

fn encode_mir(ecx: &EncodeContext, rbml_w: &mut Encoder, ii: InlinedItemRef) {
let id = match ii {
let node_id = match ii {
InlinedItemRef::Item(item) => item.id,
InlinedItemRef::TraitItem(_, trait_item) => trait_item.id,
InlinedItemRef::ImplItem(_, impl_item) => impl_item.id,
InlinedItemRef::Foreign(foreign_item) => foreign_item.id
};

if let Some(mir) = ecx.mir_map.get(&id) {
encode_mir(ecx, rbml_w, node_id);
}

fn encode_mir(ecx: &EncodeContext, rbml_w: &mut Encoder, node_id: NodeId) {
if let Some(mir) = ecx.mir_map.get(&node_id) {
rbml_w.start_tag(tag_mir as usize);
rbml_w.emit_opaque(|opaque_encoder| {
tls::enter_encoding_context(ecx, opaque_encoder, |_, opaque_encoder| {
Expand Down Expand Up @@ -1436,6 +1436,9 @@ fn my_visit_expr(expr: &hir::Expr,

ecx.tcx.map.with_path(expr.id, |path| encode_path(rbml_w, path));

assert!(ecx.mir_map.contains_key(&expr.id));
encode_mir(ecx, rbml_w, expr.id);

rbml_w.end_tag();
}
_ => { }
Expand Down

0 comments on commit c8a547a

Please sign in to comment.