diff options
| author | bors <bors@rust-lang.org> | 2014-10-03 05:02:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-10-03 05:02:37 +0000 |
| commit | aa034cd3bac3155e0f6c74c399314b5ee32f88fc (patch) | |
| tree | 891acff8f9158a69e1884707ca3bfb70d749db2e /src/libstd | |
| parent | d0af3feebb57bc58c52de69ab51f92dc7082500b (diff) | |
| parent | d911936dbdc645133ad9605f45d2bf10b73e2b20 (diff) | |
| download | rust-aa034cd3bac3155e0f6c74c399314b5ee32f88fc.tar.gz rust-aa034cd3bac3155e0f6c74c399314b5ee32f88fc.zip | |
auto merge of #17725 : alexcrichton/rust/rollup, r=alexcrichton
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/gc.rs | 156 | ||||
| -rw-r--r-- | src/libstd/io/process.rs | 4 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sync/future.rs | 5 |
4 files changed, 7 insertions, 164 deletions
diff --git a/src/libstd/gc.rs b/src/libstd/gc.rs deleted file mode 100644 index ecef8e9ed90..00000000000 --- a/src/libstd/gc.rs +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2013 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. - -/*! Task-local garbage-collected boxes - -The `Gc` type provides shared ownership of an immutable value. Destruction is not deterministic, and -will occur some time between every `Gc` handle being gone and the end of the task. The garbage -collector is task-local so `Gc<T>` is not sendable. - -*/ - -#![experimental] -#![allow(experimental)] - -use clone::Clone; -use cmp::{Ord, PartialOrd, Ordering, Eq, PartialEq}; -use default::Default; -use fmt; -use hash; -use kinds::marker; -use option::Option; -use ops::Deref; -use raw; - -/// Immutable garbage-collected pointer type -#[lang="gc"] -#[experimental = "Gc is currently based on reference-counting and will not collect cycles until \ - task annihilation. For now, cycles need to be broken manually by using `Rc<T>` \ - with a non-owning `Weak<T>` pointer. A tracing garbage collector is planned."] -pub struct Gc<T> { - _ptr: *mut T, - marker: marker::NoSend, -} - -#[unstable] -impl<T> Clone for Gc<T> { - /// Clone the pointer only - #[inline] - fn clone(&self) -> Gc<T> { *self } -} - -/// An value that represents the task-local managed heap. -/// -/// Use this like `let foo = box(GC) Bar::new(...);` -#[lang="managed_heap"] -#[cfg(not(test))] -pub static GC: () = (); - -impl<T: PartialEq + 'static> PartialEq for Gc<T> { - #[inline] - fn eq(&self, other: &Gc<T>) -> bool { *(*self) == *(*other) } - #[inline] - fn ne(&self, other: &Gc<T>) -> bool { *(*self) != *(*other) } -} -impl<T: PartialOrd + 'static> PartialOrd for Gc<T> { - #[inline] - fn partial_cmp(&self, other: &Gc<T>) -> Option<Ordering> { - (**self).partial_cmp(&**other) - } - #[inline] - fn lt(&self, other: &Gc<T>) -> bool { *(*self) < *(*other) } - #[inline] - fn le(&self, other: &Gc<T>) -> bool { *(*self) <= *(*other) } - #[inline] - fn ge(&self, other: &Gc<T>) -> bool { *(*self) >= *(*other) } - #[inline] - fn gt(&self, other: &Gc<T>) -> bool { *(*self) > *(*other) } -} -impl<T: Ord + 'static> Ord for Gc<T> { - #[inline] - fn cmp(&self, other: &Gc<T>) -> Ordering { (**self).cmp(&**other) } -} -impl<T: Eq + 'static> Eq for Gc<T> {} - -impl<T: 'static> Deref<T> for Gc<T> { - fn deref<'a>(&'a self) -> &'a T { &**self } -} - -impl<T: Default + 'static> Default for Gc<T> { - fn default() -> Gc<T> { - box(GC) Default::default() - } -} - -impl<T: 'static> raw::Repr<*const raw::GcBox<T>> for Gc<T> {} - -impl<S: hash::Writer, T: hash::Hash<S> + 'static> hash::Hash<S> for Gc<T> { - fn hash(&self, s: &mut S) { - (**self).hash(s) - } -} - -impl<T: 'static + fmt::Show> fmt::Show for Gc<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - (**self).fmt(f) - } -} - -#[cfg(test)] -mod tests { - use prelude::*; - use super::*; - use cell::RefCell; - - #[test] - fn test_managed_clone() { - let a = box(GC) 5i; - let b: Gc<int> = a.clone(); - assert!(a == b); - } - - #[test] - fn test_clone() { - let x = Gc::new(RefCell::new(5)); - let y = x.clone(); - *x.borrow().borrow_mut() = 20; - assert_eq!(*y.borrow().borrow(), 20); - } - - #[test] - fn test_simple() { - let x = Gc::new(5); - assert_eq!(*x.borrow(), 5); - } - - #[test] - fn test_simple_clone() { - let x = Gc::new(5); - let y = x.clone(); - assert_eq!(*x.borrow(), 5); - assert_eq!(*y.borrow(), 5); - } - - #[test] - fn test_ptr_eq() { - let x = Gc::new(5); - let y = x.clone(); - let z = Gc::new(7); - assert!(x.ptr_eq(&x)); - assert!(x.ptr_eq(&y)); - assert!(!x.ptr_eq(&z)); - } - - #[test] - fn test_destructor() { - let x = Gc::new(box 5); - assert_eq!(**x.borrow(), 5); - } -} diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 5220e5c984a..d8be92e4514 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -958,7 +958,9 @@ mod tests { // don't check windows magical empty-named variables assert!(k.is_empty() || output.as_slice() - .contains(format!("{}={}", *k, *v).as_slice())); + .contains(format!("{}={}", *k, *v).as_slice()), + "output doesn't contain `{}={}`\n{}", + k, v, output); } } #[cfg(target_os="android")] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 7304871cf21..c7e8da09e69 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -105,7 +105,7 @@ html_root_url = "http://doc.rust-lang.org/master/", html_playground_url = "http://play.rust-lang.org/")] -#![feature(macro_rules, globs, managed_boxes, linkage)] +#![feature(macro_rules, globs, linkage)] #![feature(default_type_params, phase, lang_items, unsafe_destructor)] #![feature(import_shadowing)] @@ -136,7 +136,6 @@ extern crate rustrt; #[cfg(test)] pub use realstd::cmp; #[cfg(test)] pub use realstd::ty; #[cfg(test)] pub use realstd::boxed; -#[cfg(test)] pub use realstd::gc; // NB: These reexports are in the order they should be listed in rustdoc @@ -219,9 +218,6 @@ pub mod rand; pub mod ascii; -#[cfg(not(test))] -pub mod gc; - pub mod time; /* Common traits */ diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs index 78da605143d..621c08fe7bc 100644 --- a/src/libstd/sync/future.rs +++ b/src/libstd/sync/future.rs @@ -201,12 +201,13 @@ mod test { #[test] fn test_sendable_future() { let expected = "schlorf"; + let (tx, rx) = channel(); let f = Future::spawn(proc() { expected }); task::spawn(proc() { let mut f = f; - let actual = f.get(); - assert_eq!(actual, expected); + tx.send(f.get()); }); + assert_eq!(rx.recv(), expected); } #[test] |
