diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-03-01 07:01:48 -0800 |
|---|---|---|
| committer | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-03-01 07:01:48 -0800 |
| commit | 85fecd0ba77066e604cec9d3866b76edc626b5d3 (patch) | |
| tree | a375b9e61af4c5e105b58271c9381fdaf58d31b0 /src/libcore | |
| parent | d2c4b6492dbccc1bb60f163ac583467bc63abce6 (diff) | |
| parent | a660bb362ce5a39014fb274367e6361d4deb8a7d (diff) | |
| download | rust-85fecd0ba77066e604cec9d3866b76edc626b5d3.tar.gz rust-85fecd0ba77066e604cec9d3866b76edc626b5d3.zip | |
Merge remote-tracking branch 'remotes/origin/incoming' into incoming
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/cell.rs | 2 | ||||
| -rw-r--r-- | src/libcore/comm.rs | 9 | ||||
| -rw-r--r-- | src/libcore/condition.rs | 4 | ||||
| -rw-r--r-- | src/libcore/core.rc | 4 | ||||
| -rw-r--r-- | src/libcore/dlist.rs | 6 | ||||
| -rw-r--r-- | src/libcore/dvec.rs | 27 | ||||
| -rw-r--r-- | src/libcore/hashmap.rs | 13 | ||||
| -rw-r--r-- | src/libcore/io.rs | 14 | ||||
| -rw-r--r-- | src/libcore/mutable.rs | 2 | ||||
| -rw-r--r-- | src/libcore/option.rs | 6 | ||||
| -rw-r--r-- | src/libcore/os.rs | 20 | ||||
| -rw-r--r-- | src/libcore/path.rs | 8 | ||||
| -rw-r--r-- | src/libcore/pipes.rs | 6 | ||||
| -rw-r--r-- | src/libcore/private.rs | 194 | ||||
| -rw-r--r-- | src/libcore/private/extfmt.rs | 2 | ||||
| -rw-r--r-- | src/libcore/private/finally.rs | 23 | ||||
| -rw-r--r-- | src/libcore/rand.rs | 14 | ||||
| -rw-r--r-- | src/libcore/reflect.rs | 2 | ||||
| -rw-r--r-- | src/libcore/repr.rs | 6 | ||||
| -rw-r--r-- | src/libcore/result.rs | 6 | ||||
| -rw-r--r-- | src/libcore/run.rs | 2 | ||||
| -rw-r--r-- | src/libcore/stackwalk.rs | 3 | ||||
| -rw-r--r-- | src/libcore/str.rs | 1 | ||||
| -rw-r--r-- | src/libcore/task/local_data_priv.rs | 2 | ||||
| -rw-r--r-- | src/libcore/task/mod.rs | 2 | ||||
| -rw-r--r-- | src/libcore/vec.rs | 3 |
26 files changed, 83 insertions, 298 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 5887df6802f..6c35c62c3a7 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -28,7 +28,7 @@ pub pure fn empty_cell<T>() -> Cell<T> { Cell { value: None } } -impl<T> Cell<T> { +pub impl<T> Cell<T> { /// Yields the value, failing if the cell is empty. fn take() -> T { if self.is_empty() { diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index 7939644e51c..b0825816626 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Transitional -- needs snapshot -#[allow(structural_records)]; - use either::{Either, Left, Right}; use kinds::Owned; use option; @@ -190,7 +187,7 @@ pub fn PortSet<T: Owned>() -> PortSet<T>{ } } -impl<T: Owned> PortSet<T> { +pub impl<T: Owned> PortSet<T> { fn add(port: Port<T>) { self.ports.push(port) @@ -323,12 +320,12 @@ pub fn oneshot<T: Owned>() -> (PortOne<T>, ChanOne<T>) { (port, chan) } -impl<T: Owned> PortOne<T> { +pub impl<T: Owned> PortOne<T> { fn recv(self) -> T { recv_one(self) } fn try_recv(self) -> Option<T> { try_recv_one(self) } } -impl<T: Owned> ChanOne<T> { +pub impl<T: Owned> ChanOne<T> { fn send(self, data: T) { send_one(self, data) } fn try_send(self, data: T) -> bool { try_send_one(self, data) } } diff --git a/src/libcore/condition.rs b/src/libcore/condition.rs index a7c8c1f4d66..00048beae5a 100644 --- a/src/libcore/condition.rs +++ b/src/libcore/condition.rs @@ -25,7 +25,7 @@ pub struct Condition<T, U> { key: task::local_data::LocalDataKey<Handler<T, U>> } -impl<T, U> Condition<T, U> { +pub impl<T, U> Condition<T, U> { fn trap(&self, h: &self/fn(T) -> U) -> Trap/&self<T, U> { unsafe { let p : *RustClosure = ::cast::transmute(&h); @@ -69,7 +69,7 @@ struct Trap<T, U> { handler: @Handler<T, U> } -impl<T, U> Trap<T, U> { +pub impl<T, U> Trap<T, U> { fn in<V>(&self, inner: &self/fn() -> V) -> V { unsafe { let _g = Guard { cond: self.cond }; diff --git a/src/libcore/core.rc b/src/libcore/core.rc index ed18388f578..91eb61e342e 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -227,10 +227,6 @@ pub const debug : u32 = 4_u32; // The runtime interface used by the compiler #[cfg(notest)] pub mod rt; -// The runtime and compiler interface to fmt! -#[cfg(stage0)] -#[path = "private/extfmt.rs"] -pub mod extfmt; // Private APIs pub mod private; diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 35807364889..f1f4e558661 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -62,7 +62,7 @@ priv impl<T> DListNode<T> { } } -impl<T> DListNode<T> { +pub impl<T> DListNode<T> { /// Get the next node in the list, if there is one. pure fn next_link(@mut self) -> DListLink<T> { self.assert_links(); @@ -208,7 +208,7 @@ priv impl<T> DList<T> { } } -impl<T> DList<T> { +pub impl<T> DList<T> { /// Get the size of the list. O(1). pure fn len(@mut self) -> uint { self.size } /// Returns true if the list is empty. O(1). @@ -457,7 +457,7 @@ impl<T> DList<T> { } } -impl<T:Copy> DList<T> { +pub impl<T:Copy> DList<T> { /// Remove data from the head of the list. O(1). fn pop(@mut self) -> Option<T> { self.pop_n().map(|nobe| nobe.data) diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index 9f2036c5f41..1fef4ad42f1 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -93,17 +93,6 @@ priv impl<A> DVec<A> { } #[inline(always)] - fn check_out<B>(f: &fn(v: ~[A]) -> B) -> B { - unsafe { - let mut data = cast::reinterpret_cast(&null::<()>()); - data <-> self.data; - let data_ptr: *() = cast::reinterpret_cast(&data); - if data_ptr.is_null() { fail!(~"Recursive use of dvec"); } - return f(data); - } - } - - #[inline(always)] fn give_back(data: ~[A]) { unsafe { self.data = data; @@ -117,7 +106,19 @@ priv impl<A> DVec<A> { // In theory, most everything should work with any A, but in practice // almost nothing works without the copy bound due to limitations // around closures. -impl<A> DVec<A> { +pub impl<A> DVec<A> { + // FIXME (#3758): This should not need to be public. + #[inline(always)] + fn check_out<B>(f: &fn(v: ~[A]) -> B) -> B { + unsafe { + let mut data = cast::reinterpret_cast(&null::<()>()); + data <-> self.data; + let data_ptr: *() = cast::reinterpret_cast(&data); + if data_ptr.is_null() { fail!(~"Recursive use of dvec"); } + return f(data); + } + } + /// Reserves space for N elements fn reserve(count: uint) { vec::reserve(&mut self.data, count) @@ -215,7 +216,7 @@ impl<A> DVec<A> { } } -impl<A:Copy> DVec<A> { +pub impl<A:Copy> DVec<A> { /** * Append all elements of a vector to the end of the list * diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index 07c7780898f..c2a39cfdcc3 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -10,14 +10,12 @@ //! Sendable hash maps. -use container::{Container, Mutable, Map, Set}; -use cmp::Eq; -use hash::Hash; -use to_bytes::IterBytes; - /// Open addressing with linear probing. pub mod linear { - use super::*; + use container::{Container, Mutable, Map, Set}; + use cmp::Eq; + use hash::Hash; + use to_bytes::IterBytes; use iter::BaseIter; use hash::Hash; use iter; @@ -752,7 +750,8 @@ mod test_map { #[test] mod test_set { - use super::*; + use hashmap::linear; + use container::{Container, Mutable, Map, Set}; use vec; #[test] diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 45d89b29a2e..fdb622f6539 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -504,7 +504,7 @@ pub fn FILE_reader(f: *libc::FILE, cleanup: bool) -> @Reader { pub fn stdin() -> @Reader { unsafe { - rustrt::rust_get_stdin() as @Reader + @rustrt::rust_get_stdin() as @Reader } } @@ -642,11 +642,11 @@ impl Writer for *libc::FILE { } } -pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> Writer { +pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> @Writer { if cleanup { - Wrapper { base: f, cleanup: FILERes(f) } as Writer + @Wrapper { base: f, cleanup: FILERes(f) } as @Writer } else { - f as Writer + @f as @Writer } } @@ -702,11 +702,11 @@ pub fn FdRes(fd: fd_t) -> FdRes { } } -pub fn fd_writer(fd: fd_t, cleanup: bool) -> Writer { +pub fn fd_writer(fd: fd_t, cleanup: bool) -> @Writer { if cleanup { - Wrapper { base: fd, cleanup: FdRes(fd) } as Writer + @Wrapper { base: fd, cleanup: FdRes(fd) } as @Writer } else { - fd as Writer + @fd as @Writer } } diff --git a/src/libcore/mutable.rs b/src/libcore/mutable.rs index 1fb855520ba..f888fbdb40c 100644 --- a/src/libcore/mutable.rs +++ b/src/libcore/mutable.rs @@ -43,7 +43,7 @@ pub fn unwrap<T>(m: Mut<T>) -> T { value } -impl<T> Data<T> { +pub impl<T> Data<T> { fn borrow_mut<R>(op: &fn(t: &mut T) -> R) -> R { match self.mode { Immutable => fail!(fmt!("%? currently immutable", diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 12ed0df0076..53944c4c2c8 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -281,7 +281,7 @@ pub pure fn expect<T>(opt: Option<T>, reason: &str) -> T { } } -impl<T> Option<T> { +pub impl<T> Option<T> { /// Returns true if the option equals `none` #[inline(always)] pure fn is_none(&self) -> bool { is_none(self) } @@ -393,7 +393,7 @@ impl<T> Option<T> { pure fn expect(self, reason: &str) -> T { expect(self, reason) } } -impl<T:Copy> Option<T> { +pub impl<T:Copy> Option<T> { /** Gets the value out of an option @@ -421,7 +421,7 @@ impl<T:Copy> Option<T> { } } -impl<T:Copy + Zero> Option<T> { +pub impl<T:Copy + Zero> Option<T> { #[inline(always)] pure fn get_or_zero(self) -> T { get_or_zero(self) } } diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 2522e9c2cda..8b6d27496d9 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -1021,10 +1021,10 @@ extern { pub mod consts { #[cfg(unix)] - use os::consts::unix::*; + pub use os::consts::unix::*; #[cfg(windows)] - use os::consts::windows::*; + pub use os::consts::windows::*; pub mod unix { pub const FAMILY: &str = "unix"; @@ -1035,19 +1035,19 @@ pub mod consts { } #[cfg(target_os = "macos")] - use os::consts::macos::*; + pub use os::consts::macos::*; #[cfg(target_os = "freebsd")] - use os::consts::freebsd::*; + pub use os::consts::freebsd::*; #[cfg(target_os = "linux")] - use os::consts::linux::*; + pub use os::consts::linux::*; #[cfg(target_os = "android")] - use os::consts::android::*; + pub use os::consts::android::*; #[cfg(target_os = "win32")] - use os::consts::win32::*; + pub use os::consts::win32::*; pub mod macos { pub const SYSNAME: &str = "macos"; @@ -1086,13 +1086,13 @@ pub mod consts { #[cfg(target_arch = "x86")] - use os::consts::x86::*; + pub use os::consts::x86::*; #[cfg(target_arch = "x86_64")] - use os::consts::x86_64::*; + pub use os::consts::x86_64::*; #[cfg(target_arch = "arm")] - use os::consts::arm::*; + pub use os::consts::arm::*; pub mod x86 { pub const ARCH: &str = "x86"; diff --git a/src/libcore/path.rs b/src/libcore/path.rs index 1753862649f..4e0e4e93cf5 100644 --- a/src/libcore/path.rs +++ b/src/libcore/path.rs @@ -241,7 +241,7 @@ mod stat { } -impl Path { +pub impl Path { fn stat(&self) -> Option<libc::stat> { unsafe { do str::as_c_str(self.to_str()) |buf| { @@ -290,7 +290,7 @@ impl Path { #[cfg(target_os = "freebsd")] #[cfg(target_os = "linux")] #[cfg(target_os = "macos")] -impl Path { +pub impl Path { fn get_atime(&self) -> Option<(i64, int)> { match self.stat() { None => None, @@ -324,7 +324,7 @@ impl Path { #[cfg(target_os = "freebsd")] #[cfg(target_os = "macos")] -impl Path { +pub impl Path { fn get_birthtime(&self) -> Option<(i64, int)> { match self.stat() { None => None, @@ -337,7 +337,7 @@ impl Path { } #[cfg(target_os = "win32")] -impl Path { +pub impl Path { fn get_atime(&self) -> Option<(i64, int)> { match self.stat() { None => None, diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index a0a29c6b516..77554656913 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -82,8 +82,6 @@ bounded and unbounded protocols allows for less code duplication. */ -#[allow(structural_records)]; // Macros -- needs another snapshot - use cmp::Eq; use cast::{forget, reinterpret_cast, transmute}; use cell::Cell; @@ -800,7 +798,7 @@ pub fn SendPacketBuffered<T,Tbuffer>(p: *Packet<T>) } } -impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> { +pub impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> { fn unwrap() -> *Packet<T> { let mut p = None; p <-> self.p; @@ -857,7 +855,7 @@ impl<T:Owned,Tbuffer:Owned> ::ops::Drop for RecvPacketBuffered<T,Tbuffer> { } } -impl<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> { +pub impl<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> { fn unwrap() -> *Packet<T> { let mut p = None; p <-> self.p; diff --git a/src/libcore/private.rs b/src/libcore/private.rs index e4fab18966c..d19951e76db 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -107,20 +107,9 @@ fn compare_and_swap(address: &mut int, oldval: int, newval: int) -> bool { * Shared state & exclusive ARC ****************************************************************************/ -struct UnwrapProtoInner { - contents: Option<(comm::ChanOne<()>, comm::PortOne<bool>)>, -} - -// An unwrapper uses this protocol to communicate with the "other" task that -// drops the last refcount on an arc. Unfortunately this can't be a proper -// pipe protocol because the unwrapper has to access both stages at once. -type UnwrapProto = ~UnwrapProtoInner; - struct ArcData<T> { mut count: libc::intptr_t, - mut unwrapper: int, // either a UnwrapProto or 0 - // FIXME(#3224) should be able to make this non-option to save memory, and - // in unwrap() use "let ~ArcData { data: result, _ } = thing" to unwrap it + // FIXME(#3224) should be able to make this non-option to save memory mut data: Option<T>, } @@ -131,37 +120,13 @@ struct ArcDestruct<T> { impl<T> Drop for ArcDestruct<T>{ fn finalize(&self) { unsafe { - if self.data.is_null() { - return; // Happens when destructing an unwrapper's handle. - } do task::unkillable { let data: ~ArcData<T> = cast::reinterpret_cast(&self.data); let new_count = intrinsics::atomic_xsub(&mut data.count, 1) - 1; assert new_count >= 0; if new_count == 0 { - // Were we really last, or should we hand off to an - // unwrapper? It's safe to not xchg because the unwrapper - // will set the unwrap lock *before* dropping his/her - // reference. In effect, being here means we're the only - // *awake* task with the data. - if data.unwrapper != 0 { - let mut p: UnwrapProto = - cast::reinterpret_cast(&data.unwrapper); - let (message, response) = - option::swap_unwrap(&mut p.contents); - // Send 'ready' and wait for a response. - comm::send_one(message, ()); - // Unkillable wait. Message guaranteed to come. - if comm::recv_one(response) { - // Other task got the data. - cast::forget(data); - } else { - // Other task was killed. drop glue takes over. - } - } else { - // drop glue takes over. - } + // drop glue takes over. } else { cast::forget(data); } @@ -176,79 +141,6 @@ fn ArcDestruct<T>(data: *libc::c_void) -> ArcDestruct<T> { } } -pub unsafe fn unwrap_shared_mutable_state<T:Owned>(rc: SharedMutableState<T>) - -> T { - struct DeathThroes<T> { - mut ptr: Option<~ArcData<T>>, - mut response: Option<comm::ChanOne<bool>>, - } - - impl<T> Drop for DeathThroes<T>{ - fn finalize(&self) { - unsafe { - let response = option::swap_unwrap(&mut self.response); - // In case we get killed early, we need to tell the person who - // tried to wake us whether they should hand-off the data to - // us. - if task::failing() { - comm::send_one(response, false); - // Either this swap_unwrap or the one below (at "Got - // here") ought to run. - cast::forget(option::swap_unwrap(&mut self.ptr)); - } else { - assert self.ptr.is_none(); - comm::send_one(response, true); - } - } - } - } - - do task::unkillable { - let ptr: ~ArcData<T> = cast::reinterpret_cast(&rc.data); - let (p1,c1) = comm::oneshot(); // () - let (p2,c2) = comm::oneshot(); // bool - let mut server: UnwrapProto = ~UnwrapProtoInner { - contents: Some((c1,p2)) - }; - let serverp: int = cast::transmute(server); - // Try to put our server end in the unwrapper slot. - if compare_and_swap(&mut ptr.unwrapper, 0, serverp) { - // Got in. Step 0: Tell destructor not to run. We are now it. - rc.data = ptr::null(); - // Step 1 - drop our own reference. - let new_count = intrinsics::atomic_xsub(&mut ptr.count, 1) - 1; - //assert new_count >= 0; - if new_count == 0 { - // We were the last owner. Can unwrap immediately. - // Also we have to free the server endpoints. - let _server: UnwrapProto = cast::transmute(serverp); - option::swap_unwrap(&mut ptr.data) - // drop glue takes over. - } else { - // The *next* person who sees the refcount hit 0 will wake us. - let end_result = - DeathThroes { ptr: Some(ptr), - response: Some(c2) }; - let mut p1 = Some(p1); // argh - do task::rekillable { - comm::recv_one(option::swap_unwrap(&mut p1)); - } - // Got here. Back in the 'unkillable' without getting killed. - // Recover ownership of ptr, then take the data out. - let ptr = option::swap_unwrap(&mut end_result.ptr); - option::swap_unwrap(&mut ptr.data) - // drop glue takes over. - } - } else { - // Somebody else was trying to unwrap. Avoid guaranteed deadlock. - cast::forget(ptr); - // Also we have to free the (rejected) server endpoints. - let _server: UnwrapProto = cast::transmute(serverp); - fail!(~"Another task is already unwrapping this ARC!"); - } - } -} - /** * COMPLETELY UNSAFE. Used as a primitive for the safe versions in std::arc. * @@ -259,7 +151,7 @@ pub type SharedMutableState<T> = ArcDestruct<T>; pub unsafe fn shared_mutable_state<T:Owned>(data: T) -> SharedMutableState<T> { - let data = ~ArcData { count: 1, unwrapper: 0, data: Some(data) }; + let data = ~ArcData { count: 1, data: Some(data) }; unsafe { let ptr = cast::transmute(data); ArcDestruct(ptr) @@ -335,7 +227,7 @@ fn LittleLock() -> LittleLock { } } -impl LittleLock { +pub impl LittleLock { #[inline(always)] unsafe fn lock<T>(f: fn() -> T) -> T { struct Unlock { @@ -381,7 +273,7 @@ impl<T:Owned> Clone for Exclusive<T> { } } -impl<T:Owned> Exclusive<T> { +pub impl<T:Owned> Exclusive<T> { // Exactly like std::arc::mutex_arc,access(), but with the little_lock // instead of a proper mutex. Same reason for being unsafe. // @@ -413,14 +305,6 @@ impl<T:Owned> Exclusive<T> { } } -// FIXME(#3724) make this a by-move method on the exclusive -pub fn unwrap_exclusive<T:Owned>(arc: Exclusive<T>) -> T { - let Exclusive { x: x } = arc; - let inner = unsafe { unwrap_shared_mutable_state(x) }; - let ExData { data: data, _ } = inner; - data -} - #[cfg(test)] pub mod tests { use core::option::{None, Some}; @@ -428,7 +312,7 @@ pub mod tests { use cell::Cell; use comm; use option; - use private::{exclusive, unwrap_exclusive}; + use private::exclusive; use result; use task; use uint; @@ -479,70 +363,4 @@ pub mod tests { assert *one == 1; } } - - #[test] - pub fn exclusive_unwrap_basic() { - let x = exclusive(~~"hello"); - assert unwrap_exclusive(x) == ~~"hello"; - } - - #[test] - pub fn exclusive_unwrap_contended() { - let x = exclusive(~~"hello"); - let x2 = Cell(x.clone()); - do task::spawn { - let x2 = x2.take(); - do x2.with |_hello| { } - task::yield(); - } - assert unwrap_exclusive(x) == ~~"hello"; - - // Now try the same thing, but with the child task blocking. - let x = exclusive(~~"hello"); - let x2 = Cell(x.clone()); - let mut res = None; - do task::task().future_result(|+r| res = Some(r)).spawn { - let x2 = x2.take(); - assert unwrap_exclusive(x2) == ~~"hello"; - } - // Have to get rid of our reference before blocking. - { let _x = x; } // FIXME(#3161) util::ignore doesn't work here - let res = option::swap_unwrap(&mut res); - res.recv(); - } - - #[test] #[should_fail] #[ignore(cfg(windows))] - pub fn exclusive_unwrap_conflict() { - let x = exclusive(~~"hello"); - let x2 = Cell(x.clone()); - let mut res = None; - do task::task().future_result(|+r| res = Some(r)).spawn { - let x2 = x2.take(); - assert unwrap_exclusive(x2) == ~~"hello"; - } - assert unwrap_exclusive(x) == ~~"hello"; - let res = option::swap_unwrap(&mut res); - // See #4689 for why this can't be just "res.recv()". - assert res.recv() == task::Success; - } - - #[test] #[ignore(cfg(windows))] - pub fn exclusive_unwrap_deadlock() { - // This is not guaranteed to get to the deadlock before being killed, - // but it will show up sometimes, and if the deadlock were not there, - // the test would nondeterministically fail. - let result = do task::try { - // a task that has two references to the same exclusive will - // deadlock when it unwraps. nothing to be done about that. - let x = exclusive(~~"hello"); - let x2 = x.clone(); - do task::spawn { - for 10.times { task::yield(); } // try to let the unwrapper go - fail!(); // punt it awake from its deadlock - } - let _z = unwrap_exclusive(x); - do x2.with |_hello| { } - }; - assert result.is_err(); - } } diff --git a/src/libcore/private/extfmt.rs b/src/libcore/private/extfmt.rs index 36ea67ea695..616d37a133a 100644 --- a/src/libcore/private/extfmt.rs +++ b/src/libcore/private/extfmt.rs @@ -142,7 +142,7 @@ pub mod ct { next: uint } - impl<T> Parsed<T> { + pub impl<T> Parsed<T> { static pure fn new(val: T, next: uint) -> Parsed<T> { Parsed {val: val, next: next} } diff --git a/src/libcore/private/finally.rs b/src/libcore/private/finally.rs index af7197159ca..ff75963511c 100644 --- a/src/libcore/private/finally.rs +++ b/src/libcore/private/finally.rs @@ -26,33 +26,10 @@ do || { use ops::Drop; use task::{spawn, failing}; -#[cfg(stage0)] -pub trait Finally<T> { - fn finally(&self, +dtor: &fn()) -> T; -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] pub trait Finally<T> { fn finally(&self, dtor: &fn()) -> T; } -#[cfg(stage0)] -impl<T> Finally<T> for &fn() -> T { - // FIXME #4518: Should not require a mode here - fn finally(&self, +dtor: &fn()) -> T { - let _d = Finallyalizer { - dtor: dtor - }; - - (*self)() - } -} - -#[cfg(stage1)] -#[cfg(stage2)] -#[cfg(stage3)] impl<T> Finally<T> for &fn() -> T { fn finally(&self, dtor: &fn()) -> T { let _d = Finallyalizer { diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index 15362f89e3f..d9c2b91fb97 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -141,7 +141,7 @@ pub struct Weighted<T> { } /// Extension methods for random number generators -impl Rng { +pub impl Rng { /// Return a random value for a Rand type fn gen<T:Rand>() -> T { Rand::rand(self) @@ -412,8 +412,8 @@ pub fn Rng() -> Rng { * all other generators constructed with the same seed. The seed may be any * length. */ -pub fn seeded_rng(seed: &[u8]) -> Rng { - seeded_randres(seed) as Rng +pub fn seeded_rng(seed: &[u8]) -> @Rng { + @seeded_randres(seed) as @Rng } fn seeded_randres(seed: &[u8]) -> @RandRes { @@ -449,8 +449,8 @@ pub pure fn xorshift() -> Rng { seeded_xorshift(123456789u32, 362436069u32, 521288629u32, 88675123u32) } -pub pure fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> Rng { - XorShiftState { x: x, y: y, z: z, w: w } as Rng +pub pure fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> @Rng { + @XorShiftState { x: x, y: y, z: z, w: w } as @Rng } @@ -472,10 +472,10 @@ pub fn task_rng() -> Rng { unsafe { let rng = seeded_randres(seed()); task::local_data::local_data_set(tls_rng_state, rng); - rng as Rng + @rng as @Rng } } - Some(rng) => rng as Rng + Some(rng) => @rng as @Rng } } diff --git a/src/libcore/reflect.rs b/src/libcore/reflect.rs index ed7e485678e..2a688482f61 100644 --- a/src/libcore/reflect.rs +++ b/src/libcore/reflect.rs @@ -45,7 +45,7 @@ pub fn MovePtrAdaptor<V:TyVisitor + MovePtr>(v: V) -> MovePtrAdaptor<V> { MovePtrAdaptor { inner: v } } -impl<V:TyVisitor + MovePtr> MovePtrAdaptor<V> { +pub impl<V:TyVisitor + MovePtr> MovePtrAdaptor<V> { #[inline(always)] fn bump(sz: uint) { do self.inner.move_ptr() |p| { diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index 4c3abb09756..af135339b2e 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -167,7 +167,7 @@ impl MovePtr for ReprVisitor { } } -impl ReprVisitor { +pub impl ReprVisitor { // Various helpers for the TyVisitor impl @@ -201,7 +201,7 @@ impl ReprVisitor { unsafe { let mut u = ReprVisitor(ptr, self.writer); let v = reflect::MovePtrAdaptor(u); - visit_tydesc(inner, (v) as @TyVisitor); + visit_tydesc(inner, @v as @TyVisitor); true } } @@ -570,7 +570,7 @@ pub fn write_repr<T>(writer: @Writer, object: &T) { let tydesc = intrinsic::get_tydesc::<T>(); let mut u = ReprVisitor(ptr, writer); let v = reflect::MovePtrAdaptor(u); - visit_tydesc(tydesc, (v) as @TyVisitor) + visit_tydesc(tydesc, @v as @TyVisitor) } } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index b03eaeab3e0..ddcd1547841 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -228,7 +228,7 @@ pub pure fn map_err<T:Copy,E,F:Copy>(res: &Result<T, E>, op: fn(&E) -> F) } } -impl<T, E> Result<T, E> { +pub impl<T, E> Result<T, E> { #[inline(always)] pure fn get_ref(&self) -> &self/T { get_ref(self) } @@ -261,7 +261,7 @@ impl<T, E> Result<T, E> { } } -impl<T:Copy,E> Result<T, E> { +pub impl<T:Copy,E> Result<T, E> { #[inline(always)] pure fn get(&self) -> T { get(self) } @@ -271,7 +271,7 @@ impl<T:Copy,E> Result<T, E> { } } -impl<T, E: Copy> Result<T, E> { +pub impl<T, E: Copy> Result<T, E> { #[inline(always)] pure fn get_err(&self) -> E { get_err(self) } diff --git a/src/libcore/run.rs b/src/libcore/run.rs index aa1e473e3bf..e8cd9caaef6 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -288,7 +288,7 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program { finished: false, }; - ProgRes(repr) as Program + @ProgRes(repr) as @Program } fn read_all(rd: io::Reader) -> ~str { diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs index 2e24df86c78..8950a1d0c02 100644 --- a/src/libcore/stackwalk.rs +++ b/src/libcore/stackwalk.rs @@ -10,9 +10,6 @@ #[doc(hidden)]; // FIXME #3538 -#[legacy_modes]; // tjc: remove after snapshot -#[allow(deprecated_mode)]; - use cast::reinterpret_cast; use ptr::offset; use sys::size_of; diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 66be5481819..6ee6d282841 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -2375,6 +2375,7 @@ impl OwnedStr for ~str { #[cfg(test)] mod tests { use char; + use option::Some; use debug; use libc::c_char; use libc; diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index 3ac457b23d1..df5a5af74ca 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -155,7 +155,7 @@ pub unsafe fn local_set<T:Durable>( // does not have a reference associated with it, so it may become invalid // when the box is destroyed. let data_ptr = cast::reinterpret_cast(&data); - let data_box = data as LocalData; + let data_box = @data as @LocalData; // Construct new entry to store in the map. let new_entry = Some((keyval, data_ptr, data_box)); // Find a place to put it. diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index 2a640e4bf8c..49507897392 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -232,7 +232,7 @@ priv impl TaskBuilder { } } -impl TaskBuilder { +pub impl TaskBuilder { /** * Decouple the child task's failure from the parent's. If either fails, * the other will not be killed. diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 687ad2f7938..4d28c769b18 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -1444,7 +1444,7 @@ pub fn each2<U, T>(v1: &[U], v2: &[T], f: fn(u: &U, t: &T) -> bool) { * The total number of permutations produced is `len(v)!`. If `v` contains * repeated elements, then some permutations are repeated. */ -pure fn each_permutation<T:Copy>(v: &[T], put: fn(ts: &[T]) -> bool) { +pub pure fn each_permutation<T:Copy>(v: &[T], put: fn(ts: &[T]) -> bool) { let ln = len(v); if ln <= 1 { put(v); @@ -2427,6 +2427,7 @@ impl<A:Copy> iter::CopyableNonstrictIter<A> for @[A] { mod tests { use option::{None, Option, Some}; use option; + use sys; use vec::*; fn square(n: uint) -> uint { return n * n; } |
