diff --git a/src/lib/str.rs b/src/lib/str.rs index 388ed3d5825..9df30a38587 100644 --- a/src/lib/str.rs +++ b/src/lib/str.rs @@ -336,8 +336,9 @@ fn refcount(str s) -> uint { if (r == dbg::const_refcount) { ret r; } else { - // -1 because calling this function incremented the refcount. - ret r - 1u; + // -2 because calling this function and the native function both + // incremented the refcount. + ret r - 2u; } } diff --git a/src/lib/vec.rs b/src/lib/vec.rs index 3815031b305..969fca9a17e 100644 --- a/src/lib/vec.rs +++ b/src/lib/vec.rs @@ -50,8 +50,9 @@ fn refcount[T](array[T] v) -> uint { if (r == dbg::const_refcount) { ret r; } else { - // -1 because calling this function incremented the refcount. - ret r - 1u; + // -2 because calling this function and the native function both + // incremented the refcount. + ret r - 2u; } } diff --git a/src/test/run-pass/vec-append.rs b/src/test/run-pass/vec-append.rs index 46b0cd6f2a1..f7404852063 100644 --- a/src/test/run-pass/vec-append.rs +++ b/src/test/run-pass/vec-append.rs @@ -1,6 +1,3 @@ -// xfail-stage0 -// xfail-stage1 -// xfail-stage2 // -*- rust -*- use std; @@ -51,13 +48,13 @@ fn slow_growth2_helper(str s) { // ref up: s * mumble, the existing str in the originally- shared vec. */ let vec[str] v = [mumble]; // ref up: v, mumble + log vec::refcount[str](v); let acc a = acc(v); // ref up: a, v log vec::refcount[str](v); assert (vec::refcount[str](v) == 2u); a.add(s); // ref up: mumble, s. ref down: v - log vec::refcount[str](v); log str::refcount(s); log str::refcount(mumble);