Skip to content

Commit e1d8806

Browse files
committed
Fix closure debuginfo.
1 parent 3f9823d commit e1d8806

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/librustc_trans/mir/mod.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010

1111
use libc::c_uint;
1212
use llvm::{self, ValueRef};
13-
use rustc::ty;
13+
use rustc::ty::{self, layout};
1414
use rustc::mir;
1515
use rustc::mir::tcx::LvalueTy;
1616
use session::config::FullDebugInfo;
1717
use base;
1818
use common::{self, Block, BlockAndBuilder, CrateContext, FunctionContext, C_null};
1919
use debuginfo::{self, declare_local, DebugLoc, VariableAccess, VariableKind, FunctionDebugContext};
20-
use machine;
2120
use type_of;
2221

2322
use syntax_pos::{DUMMY_SP, NO_EXPANSION, COMMAND_LINE_EXPN, BytePos};
@@ -494,10 +493,15 @@ fn arg_local_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>,
494493
llval
495494
};
496495

497-
let llclosurety = type_of::type_of(bcx.ccx(), closure_ty);
496+
let layout = bcx.ccx().layout_of(closure_ty);
497+
let offsets = match *layout {
498+
layout::Univariant { ref variant, .. } => &variant.offsets[..],
499+
_ => bug!("Closures are only supposed to be Univariant")
500+
};
501+
498502
for (i, (decl, ty)) in mir.upvar_decls.iter().zip(upvar_tys).enumerate() {
499-
let byte_offset_of_var_in_env =
500-
machine::llelement_offset(bcx.ccx(), llclosurety, i);
503+
let byte_offset_of_var_in_env = offsets[i].bytes();
504+
501505

502506
let ops = unsafe {
503507
[llvm::LLVMRustDIBuilderCreateOpDeref(),

0 commit comments

Comments
 (0)