Skip to content

Commit 8861e1d

Browse files
add debuginfo for unboxed closures
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.
1 parent d24c824 commit 8861e1d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/librustc/middle/trans/debuginfo.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,9 @@ impl TypeMap {
511511
unique_type_id.push_char('+');
512512
}
513513
},
514+
ty::ty_unboxed_closure(..) => {
515+
unique_type_id.push_str("closure");
516+
}
514517
_ => {
515518
cx.sess().bug(format!("get_unique_type_id_of_type() - unexpected type: {}, {:?}",
516519
ppaux::ty_to_string(cx.tcx(), type_).as_slice(),
@@ -2980,6 +2983,13 @@ fn type_metadata(cx: &CrateContext,
29802983
unique_type_id,
29812984
usage_site_span).finalize(cx)
29822985
}
2986+
ty::ty_unboxed_closure(def_id, _) => {
2987+
let unboxed_closures = cx.tcx().unboxed_closures.borrow();
2988+
let ref function_type = unboxed_closures.get(&def_id)
2989+
.closure_type;
2990+
2991+
subroutine_type_metadata(cx, unique_type_id, &function_type.sig, usage_site_span)
2992+
}
29832993
_ => {
29842994
cx.sess().bug(format!("debuginfo: unexpected type in type_metadata: {:?}",
29852995
sty).as_slice())

src/test/run-pass/unboxed-closures-unique-type-id.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10+
11+
// compile-flags:-g
12+
1013
//
1114
// This code used to produce the following ICE:
1215
//

0 commit comments

Comments
 (0)