Skip to content

Commit 0d15ae4

Browse files
committed
Modify alt-pattern-drop.rs to also insure the slot bound in the pattern doesn't also get dropped (again) at the end of the block containing the alt.
1 parent 6f52ba7 commit 0d15ae4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/test/run-pass/alt-pattern-drop.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,21 @@ import std._str;
55

66
type t = tag(make_t(str), clam());
77

8-
fn main() {
9-
let str s = "hi"; // ref up
8+
fn foo(str s) {
109
let t x = make_t(s); // ref up
1110

1211
alt (x) {
13-
case (make_t(y)) { log y; } // ref up and ref down
12+
case (make_t(y)) { log y; } // ref up then down
1413
case (_) { log "?"; fail; }
1514
}
1615

1716
log _str.refcount(s);
18-
check (_str.refcount(s) == 2u);
17+
check (_str.refcount(s) == 3u);
18+
}
19+
20+
fn main() {
21+
let str s = "hi"; // ref up
22+
foo(s); // ref up then down
23+
log _str.refcount(s);
24+
check (_str.refcount(s) == 1u);
1925
}

0 commit comments

Comments
 (0)