blob: 76e7c3aa18d79c5cf819f56f9d10ca24c5d2f72d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// -*- rust -*-
use std;
import std.Str;
// FIXME: import std.Dbg.const_refcount. Currently
// cross-crate const references don't work.
const uint const_refcount = 0x7bad_face_u;
tag t {
make_t(str);
clam;
}
fn foo(str s) {
let t x = make_t(s); // ref up
alt (x) {
case (make_t(?y)) { log y; } // ref up then down
case (_) { log "?"; fail; }
}
log Str.refcount(s);
assert (Str.refcount(s) == const_refcount);
}
fn main() {
let str s = "hi"; // ref up
foo(s); // ref up then down
log Str.refcount(s);
assert (Str.refcount(s) == const_refcount);
}
|