2010-08-27 15:27:28 -05:00
|
|
|
// -*- rust -*-
|
|
|
|
|
|
|
|
use std;
|
2011-05-12 10:24:54 -05:00
|
|
|
import std::_str;
|
2010-08-27 15:27:28 -05:00
|
|
|
|
2011-05-12 10:24:54 -05:00
|
|
|
// FIXME: import std::dbg.const_refcount. Currently
|
2010-11-09 16:15:07 -06:00
|
|
|
// cross-crate const references don't work.
|
|
|
|
const uint const_refcount = 0x7bad_face_u;
|
|
|
|
|
2010-09-09 17:59:29 -05:00
|
|
|
tag t {
|
|
|
|
make_t(str);
|
2010-09-21 01:56:43 -05:00
|
|
|
clam;
|
2010-09-09 17:59:29 -05:00
|
|
|
}
|
2010-08-27 15:27:28 -05:00
|
|
|
|
2010-08-27 15:48:45 -05:00
|
|
|
fn foo(str s) {
|
2010-08-27 15:27:28 -05:00
|
|
|
let t x = make_t(s); // ref up
|
|
|
|
|
|
|
|
alt (x) {
|
2010-09-21 01:56:43 -05:00
|
|
|
case (make_t(?y)) { log y; } // ref up then down
|
2010-08-27 15:29:48 -05:00
|
|
|
case (_) { log "?"; fail; }
|
2010-08-27 15:27:28 -05:00
|
|
|
}
|
|
|
|
|
2011-05-12 10:24:54 -05:00
|
|
|
log _str::refcount(s);
|
|
|
|
assert (_str::refcount(s) == const_refcount);
|
2010-08-27 15:48:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let str s = "hi"; // ref up
|
|
|
|
foo(s); // ref up then down
|
2011-05-12 10:24:54 -05:00
|
|
|
log _str::refcount(s);
|
|
|
|
assert (_str::refcount(s) == const_refcount);
|
2010-08-27 15:27:28 -05:00
|
|
|
}
|