Skip to content

Commit

Permalink
Create correct debuginfo for closure function signatures
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dotdash committed Jul 18, 2015
1 parent 1373c4f commit 47128b8
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/librustc_trans/trans/debuginfo/mod.rs
Expand Up @@ -30,7 +30,7 @@ use middle::subst::{self, Substs};
use rustc::ast_map;
use trans::common::{NodeIdAndSpan, CrateContext, FunctionContext, Block};
use trans;
use trans::monomorphize;
use trans::{monomorphize, type_of};
use middle::ty::{self, Ty};
use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
use util::nodemap::{NodeMap, FnvHashMap, FnvHashSet};
Expand All @@ -41,7 +41,7 @@ use std::ffi::CString;
use std::ptr;
use std::rc::Rc;
use syntax::codemap::{Span, Pos};
use syntax::{ast, codemap, ast_util};
use syntax::{abi, ast, codemap, ast_util};
use syntax::attr::IntType;
use syntax::parse::token::{self, special_idents};

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

let sig = match fn_type.sty {
let (sig, abi) = match fn_type.sty {
ty::TyBareFn(_, ref barefnty) => {
cx.tcx().erase_late_bound_regions(&barefnty.sig)
(cx.tcx().erase_late_bound_regions(&barefnty.sig), barefnty.abi)
}
ty::TyClosure(def_id, substs) => {
cx.tcx().erase_late_bound_regions(&cx.tcx().closure_type(def_id, substs).sig)
let closure_type = cx.tcx().closure_type(def_id, substs);
(cx.tcx().erase_late_bound_regions(&closure_type.sig), closure_type.abi)
}

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

let inputs = &if abi == abi::RustCall {
type_of::untuple_arguments(cx, &sig.inputs)
} else {
sig.inputs
};

// Arguments types
for &argument_type in &sig.inputs {
for &argument_type in inputs {
signature.push(type_metadata(cx, argument_type, codemap::DUMMY_SP));
}

Expand Down

0 comments on commit 47128b8

Please sign in to comment.