Skip to content

Commit 41fc5f7

Browse files
committed
mir: Trigger closure instantiations when the closure value is created.
1 parent 6c551b3 commit 41fc5f7

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/librustc_trans/trans/mir/rvalue.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,31 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
132132
}
133133
},
134134
_ => {
135+
// FIXME Shouldn't need to manually trigger closure instantiations.
136+
if let mir::AggregateKind::Closure(def_id, substs) = *kind {
137+
use rustc_front::hir;
138+
use syntax::ast::DUMMY_NODE_ID;
139+
use syntax::codemap::DUMMY_SP;
140+
use syntax::ptr::P;
141+
use trans::closure;
142+
143+
closure::trans_closure_expr(closure::Dest::Ignore(bcx.ccx()),
144+
&hir::FnDecl {
145+
inputs: P::new(),
146+
output: hir::NoReturn(DUMMY_SP),
147+
variadic: false
148+
},
149+
&hir::Block {
150+
stmts: P::new(),
151+
expr: None,
152+
id: DUMMY_NODE_ID,
153+
rules: hir::DefaultBlock,
154+
span: DUMMY_SP
155+
},
156+
DUMMY_NODE_ID, def_id,
157+
&bcx.monomorphize(substs));
158+
}
159+
135160
for (i, operand) in operands.iter().enumerate() {
136161
let op = self.trans_operand(&bcx, operand);
137162
// Do not generate stores and GEPis for zero-sized fields.

0 commit comments

Comments
 (0)