Skip to content

Commit 47128b8

Browse files
committed
Create correct debuginfo for closure function signatures
Internally, the arguments passed to the closure are represented by a tuple, but the actual function takes them as individual arguments, so we have to untuple the arguments before creating the debuginfo.
1 parent 1373c4f commit 47128b8

File tree

1 file changed

+13
-6
lines changed
  • src/librustc_trans/trans/debuginfo

1 file changed

+13
-6
lines changed

src/librustc_trans/trans/debuginfo/mod.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use middle::subst::{self, Substs};
3030
use rustc::ast_map;
3131
use trans::common::{NodeIdAndSpan, CrateContext, FunctionContext, Block};
3232
use trans;
33-
use trans::monomorphize;
33+
use trans::{monomorphize, type_of};
3434
use middle::ty::{self, Ty};
3535
use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
3636
use util::nodemap::{NodeMap, FnvHashMap, FnvHashSet};
@@ -41,7 +41,7 @@ use std::ffi::CString;
4141
use std::ptr;
4242
use std::rc::Rc;
4343
use syntax::codemap::{Span, Pos};
44-
use syntax::{ast, codemap, ast_util};
44+
use syntax::{abi, ast, codemap, ast_util};
4545
use syntax::attr::IntType;
4646
use syntax::parse::token::{self, special_idents};
4747

@@ -412,12 +412,13 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
412412
assert_type_for_node_id(cx, fn_ast_id, error_reporting_span);
413413
let fn_type = cx.tcx().node_id_to_type(fn_ast_id);
414414

415-
let sig = match fn_type.sty {
415+
let (sig, abi) = match fn_type.sty {
416416
ty::TyBareFn(_, ref barefnty) => {
417-
cx.tcx().erase_late_bound_regions(&barefnty.sig)
417+
(cx.tcx().erase_late_bound_regions(&barefnty.sig), barefnty.abi)
418418
}
419419
ty::TyClosure(def_id, substs) => {
420-
cx.tcx().erase_late_bound_regions(&cx.tcx().closure_type(def_id, substs).sig)
420+
let closure_type = cx.tcx().closure_type(def_id, substs);
421+
(cx.tcx().erase_late_bound_regions(&closure_type.sig), closure_type.abi)
421422
}
422423

423424
_ => cx.sess().bug("get_function_metdata: Expected a function type!")
@@ -435,8 +436,14 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
435436
ty::FnDiverging => diverging_type_metadata(cx)
436437
});
437438

439+
let inputs = &if abi == abi::RustCall {
440+
type_of::untuple_arguments(cx, &sig.inputs)
441+
} else {
442+
sig.inputs
443+
};
444+
438445
// Arguments types
439-
for &argument_type in &sig.inputs {
446+
for &argument_type in inputs {
440447
signature.push(type_metadata(cx, argument_type, codemap::DUMMY_SP));
441448
}
442449

0 commit comments

Comments
 (0)