2010-08-27 15:27:28 -05:00
|
|
|
|
2011-06-15 13:19:50 -05:00
|
|
|
|
|
|
|
// -*- rust -*-
|
2010-08-27 15:27:28 -05:00
|
|
|
use std;
|
|
|
|
|
2011-08-31 17:23:34 -05:00
|
|
|
import std::dbg;
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-01-19 20:31:08 -06:00
|
|
|
enum t { make_t(@int), clam, }
|
2010-08-27 15:27:28 -05:00
|
|
|
|
2011-08-31 17:23:34 -05:00
|
|
|
fn foo(s: @int) {
|
|
|
|
let count = dbg::refcount(s);
|
2011-07-27 07:19:39 -05:00
|
|
|
let x: t = make_t(s); // ref up
|
2010-08-27 15:27:28 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
alt x {
|
|
|
|
make_t(y) {
|
2011-12-22 19:53:53 -06:00
|
|
|
log(debug, y); // ref up then down
|
2010-08-27 15:27:28 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
}
|
2011-12-22 16:42:52 -06:00
|
|
|
_ { #debug("?"); fail; }
|
2011-06-15 13:19:50 -05:00
|
|
|
}
|
2011-12-22 19:53:53 -06:00
|
|
|
log(debug, dbg::refcount(s));
|
2011-08-31 17:23:34 -05:00
|
|
|
assert (dbg::refcount(s) == count + 1u);
|
2010-08-27 15:48:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2011-08-31 17:23:34 -05:00
|
|
|
let s: @int = @0; // ref up
|
2011-06-15 13:19:50 -05:00
|
|
|
|
|
|
|
foo(s); // ref up then down
|
|
|
|
|
2011-12-22 19:53:53 -06:00
|
|
|
log(debug, dbg::refcount(s));
|
2011-08-31 17:23:34 -05:00
|
|
|
assert (dbg::refcount(s) == 1u);
|
2011-08-19 17:16:48 -05:00
|
|
|
}
|