|
10 | 10 |
|
11 | 11 | use libc::c_uint;
|
12 | 12 | use llvm::{self, ValueRef};
|
13 |
| -use rustc::ty; |
| 13 | +use rustc::ty::{self, layout}; |
14 | 14 | use rustc::mir;
|
15 | 15 | use rustc::mir::tcx::LvalueTy;
|
16 | 16 | use session::config::FullDebugInfo;
|
17 | 17 | use base;
|
18 | 18 | use common::{self, Block, BlockAndBuilder, CrateContext, FunctionContext, C_null};
|
19 | 19 | use debuginfo::{self, declare_local, DebugLoc, VariableAccess, VariableKind, FunctionDebugContext};
|
20 |
| -use machine; |
21 | 20 | use type_of;
|
22 | 21 |
|
23 | 22 | 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>,
|
494 | 493 | llval
|
495 | 494 | };
|
496 | 495 |
|
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 | + |
498 | 502 | 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 | + |
501 | 505 |
|
502 | 506 | let ops = unsafe {
|
503 | 507 | [llvm::LLVMRustDIBuilderCreateOpDeref(),
|
|
0 commit comments