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.
This commit is contained in:
Björn Steinbrink 2015-07-14 19:03:13 +02:00
parent 1373c4fcf2
commit 47128b8c7e

View file

@ -30,7 +30,7 @@ use middle::subst::{self, Substs};
use rustc::ast_map; use rustc::ast_map;
use trans::common::{NodeIdAndSpan, CrateContext, FunctionContext, Block}; use trans::common::{NodeIdAndSpan, CrateContext, FunctionContext, Block};
use trans; use trans;
use trans::monomorphize; use trans::{monomorphize, type_of};
use middle::ty::{self, Ty}; use middle::ty::{self, Ty};
use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo}; use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
use util::nodemap::{NodeMap, FnvHashMap, FnvHashSet}; use util::nodemap::{NodeMap, FnvHashMap, FnvHashSet};
@ -41,7 +41,7 @@ use std::ffi::CString;
use std::ptr; use std::ptr;
use std::rc::Rc; use std::rc::Rc;
use syntax::codemap::{Span, Pos}; use syntax::codemap::{Span, Pos};
use syntax::{ast, codemap, ast_util}; use syntax::{abi, ast, codemap, ast_util};
use syntax::attr::IntType; use syntax::attr::IntType;
use syntax::parse::token::{self, special_idents}; use syntax::parse::token::{self, special_idents};
@ -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); 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 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) => { 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) => { 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!") _ => 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>,
ty::FnDiverging => diverging_type_metadata(cx) ty::FnDiverging => diverging_type_metadata(cx)
}); });
let inputs = &if abi == abi::RustCall {
type_of::untuple_arguments(cx, &sig.inputs)
} else {
sig.inputs
};
// Arguments types // Arguments types
for &argument_type in &sig.inputs { for &argument_type in inputs {
signature.push(type_metadata(cx, argument_type, codemap::DUMMY_SP)); signature.push(type_metadata(cx, argument_type, codemap::DUMMY_SP));
} }