From 0d15ae4f7a2429e70d7085e538e7ce305ef6a468 Mon Sep 17 00:00:00 2001 From: Roy Frostig Date: Fri, 27 Aug 2010 13:48:45 -0700 Subject: 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. --- src/test/run-pass/alt-pattern-drop.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/test/run-pass/alt-pattern-drop.rs b/src/test/run-pass/alt-pattern-drop.rs index 4adf2f3a..68e4f13e 100644 --- a/src/test/run-pass/alt-pattern-drop.rs +++ b/src/test/run-pass/alt-pattern-drop.rs @@ -5,15 +5,21 @@ import std._str; type t = tag(make_t(str), clam()); -fn main() { - let str s = "hi"; // ref up +fn foo(str s) { let t x = make_t(s); // ref up alt (x) { - case (make_t(y)) { log y; } // ref up and ref down + case (make_t(y)) { log y; } // ref up then down case (_) { log "?"; fail; } } log _str.refcount(s); - check (_str.refcount(s) == 2u); + check (_str.refcount(s) == 3u); +} + +fn main() { + let str s = "hi"; // ref up + foo(s); // ref up then down + log _str.refcount(s); + check (_str.refcount(s) == 1u); } -- cgit v1.2.3