Skip to content

Commit

Permalink
add debuginfo for unboxed closures
Browse files Browse the repository at this point in the history
This catches two unhandled patterns in middle/trans/debuginfo.rs where a
ty::ty_unboxed_closure could show up, preventing various potential ICEs
when #[feature(unboxed_closures)] is used with `-g`.

It also updates the test case from rust-lang#17093 in response to new information
from rust-lang#17021 showing that the test still caused an ICE when compiling
with debuginfo.

Closes rust-lang#17021.
  • Loading branch information
nathantypanski committed Sep 12, 2014
1 parent d24c824 commit 8861e1d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/librustc/middle/trans/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ impl TypeMap {
unique_type_id.push_char('+');
}
},
ty::ty_unboxed_closure(..) => {
unique_type_id.push_str("closure");
}
_ => {
cx.sess().bug(format!("get_unique_type_id_of_type() - unexpected type: {}, {:?}",
ppaux::ty_to_string(cx.tcx(), type_).as_slice(),
Expand Down Expand Up @@ -2980,6 +2983,13 @@ fn type_metadata(cx: &CrateContext,
unique_type_id,
usage_site_span).finalize(cx)
}
ty::ty_unboxed_closure(def_id, _) => {
let unboxed_closures = cx.tcx().unboxed_closures.borrow();
let ref function_type = unboxed_closures.get(&def_id)
.closure_type;

subroutine_type_metadata(cx, unique_type_id, &function_type.sig, usage_site_span)
}
_ => {
cx.sess().bug(format!("debuginfo: unexpected type in type_metadata: {:?}",
sty).as_slice())
Expand Down
3 changes: 3 additions & 0 deletions src/test/run-pass/unboxed-closures-unique-type-id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags:-g

//
// This code used to produce the following ICE:
//
Expand Down

0 comments on commit 8861e1d

Please sign in to comment.