make std::managed private

This removes two tests built on `managed::refcount`, but these issues
are well-covered elsewhere for non-managed types.
This commit is contained in:
Daniel Micay 2014-03-22 18:45:47 -04:00
parent 7e7a5e3d3e
commit 31d5ffc5bd
4 changed files with 1 additions and 87 deletions

View File

@ -134,7 +134,7 @@ pub mod ascii;
pub mod ptr;
pub mod owned;
pub mod managed;
mod managed;
mod reference;
pub mod rc;
pub mod gc;

View File

@ -12,13 +12,6 @@
#[cfg(not(test))] use cmp::*;
/// Returns the refcount of a shared box (as just before calling this)
#[inline]
pub fn refcount<T>(t: @T) -> uint {
use raw::Repr;
unsafe { (*t.repr()).ref_count - 1 }
}
/// Determine if two shared boxes point to the same object
#[inline]
pub fn ptr_eq<T>(a: @T, b: @T) -> bool {
@ -66,14 +59,3 @@ fn test() {
assert!((!ptr_eq::<int>(x, y)));
assert!((!ptr_eq::<int>(y, x)));
}
#[test]
fn refcount_test() {
use clone::Clone;
let x = @3;
assert_eq!(refcount(x), 1);
let y = x.clone();
assert_eq!(refcount(x), 2);
assert_eq!(refcount(y), 2);
}

View File

@ -1,44 +0,0 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
enum t { make_t(@int), clam, }
fn foo(s: @int) {
println!("{:?}", ::std::managed::refcount(s));
let count = ::std::managed::refcount(s);
let x: t = make_t(s); // ref up
assert_eq!(::std::managed::refcount(s), count + 1u);
println!("{:?}", ::std::managed::refcount(s));
match x {
make_t(y) => {
println!("{:?}", y); // ref up then down
}
_ => { println!("?"); fail!(); }
}
println!("{:?}", ::std::managed::refcount(s));
assert_eq!(::std::managed::refcount(s), count + 1u);
let _ = ::std::managed::refcount(s); // don't get bitten by last-use.
}
pub fn main() {
let s: @int = @0; // ref up
let count = ::std::managed::refcount(s);
foo(s); // ref up then down
println!("{}", ::std::managed::refcount(s));
let count2 = ::std::managed::refcount(s);
assert_eq!(count, count2);
}

View File

@ -1,24 +0,0 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
#[allow(unused_variable)];
use std::managed;
pub fn main() {
let i = ~@1;
let j = ~@2;
let rc1 = managed::refcount(*i);
let j = i.clone();
let rc2 = managed::refcount(*i);
println!("rc1: {} rc2: {}", rc1, rc2);
assert_eq!(rc1 + 1u, rc2);
}