aboutsummaryrefslogtreecommitdiff
path: root/src/test/run-pass/alt-pattern-drop.rs
blob: 68e4f13e34734599ead04d1a43d977e36c377fc4 (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
// -*- rust -*-

use std;
import std._str;

type t = tag(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);
  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);
}