Skip to content

Commit e7dbf42

Browse files
committed
rustc: Fix type_need_unwind_cleanup. Closes #2272
1 parent 5437a04 commit e7dbf42

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

src/rustc/middle/ty.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,8 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t,
11761176
let mut encountered_box = encountered_box;
11771177
let mut needs_unwind_cleanup = false;
11781178
maybe_walk_ty(ty) {|ty|
1179-
alt get(ty).struct {
1179+
let old_encountered_box = encountered_box;
1180+
let result = alt get(ty).struct {
11801181
ty_box(_) | ty_opaque_box {
11811182
encountered_box = true;
11821183
true
@@ -1216,7 +1217,10 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t,
12161217
needs_unwind_cleanup = true;
12171218
false
12181219
}
1219-
}
1220+
};
1221+
1222+
encountered_box = old_encountered_box;
1223+
result
12201224
}
12211225

12221226
ret needs_unwind_cleanup;

src/test/compile-fail/class-implements-int.rs

-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
// xfail-test
2-
/*
3-
tjc: currently this results in a memory leak after a call to
4-
span_fatal in typeck. I think it's the same issue as #2272, because
5-
if I make type_needs_unwind_cleanup always return true, the test passes.
6-
FIXME: Un-xfail this when #2272 is fixed.
7-
*/
81
class cat implements int { //! ERROR can only implement interface types
92
let meows: uint;
103
new(in_x : uint) { self.meows = in_x; }

src/test/compile-fail/infinite-instantiation.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// error-pattern: overly deep expansion
22
// issue 2258
3-
// This is currently exposing a memory leak, and xfailed for that reason
4-
// xfail-test
53

64
iface to_opt {
75
fn to_option() -> option<self>;

src/test/run-fail/issue-2272.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// error-pattern:explicit failure
2+
// Issue #2272 - unwind this without leaking the unique pointer
3+
4+
fn main() {
5+
let _x = {
6+
y: {
7+
z: @0
8+
},
9+
a: ~0
10+
};
11+
fail;
12+
}

0 commit comments

Comments
 (0)