diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-05-07 08:20:22 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-05-07 11:03:12 -0700 |
| commit | 07caa224501817c93be3f5c57a013ed5db6c04e1 (patch) | |
| tree | 4a7df32c0c34f78282e842b308c2751f3d3cd5ee /src/libcore | |
| parent | a289ebefb8c3584d91484f0bb62f696dffadda02 (diff) | |
| download | rust-07caa224501817c93be3f5c57a013ed5db6c04e1.tar.gz rust-07caa224501817c93be3f5c57a013ed5db6c04e1.zip | |
Test fixes and rebase conflicts
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/any.rs | 12 | ||||
| -rw-r--r-- | src/libcore/clone.rs | 5 | ||||
| -rw-r--r-- | src/libcore/cmp.rs | 25 | ||||
| -rw-r--r-- | src/libcore/lib.rs | 4 | ||||
| -rw-r--r-- | src/libcore/owned.rs | 38 |
5 files changed, 59 insertions, 25 deletions
diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 0c07bf91bd2..459015445eb 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -149,7 +149,6 @@ mod tests { use prelude::*; use super::*; use owned::Box; - use str::StrSlice; use realstd::str::StrAllocating; #[deriving(Eq, Show)] @@ -275,17 +274,10 @@ mod tests { #[test] fn test_show() { -<<<<<<< HEAD - let a = box 8u as Box<Any>; - let b = box Test as Box<Any>; + let a = box 8u as Box<::realcore::any::Any>; + let b = box Test as Box<::realcore::any::Any>; assert_eq!(format!("{}", a), "Box<Any>".to_owned()); assert_eq!(format!("{}", b), "Box<Any>".to_owned()); -======= - let a = ~8u as ~::realcore::any::Any; - let b = ~Test as ~::realcore::any::Any; - assert_eq!(format!("{}", a), "~Any".to_owned()); - assert_eq!(format!("{}", b), "~Any".to_owned()); ->>>>>>> core: Get coretest working let a = &8u as &::realcore::any::Any; let b = &Test as &::realcore::any::Any; diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index 659d797bc67..06cbaf19812 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -129,6 +129,7 @@ extern_fn_clone!(A, B, C, D, E, F, G, H) #[cfg(test)] mod test { use prelude::*; + use owned::Box; #[test] fn test_owned_clone() { @@ -154,8 +155,8 @@ mod test { #[test] fn test_clone_from() { - let a = ~5; - let mut b = ~10; + let a = box 5; + let mut b = box 10; b.clone_from(&a); assert_eq!(*b, 5); } diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 0ad2a465522..af611cd94e5 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -193,6 +193,7 @@ pub fn max<T: TotalOrd>(v1: T, v2: T) -> T { #[cfg(not(test))] mod impls { use cmp::{Ord, TotalOrd, Eq, TotalEq, Ordering}; + use owned::Box; // & pointers impl<'a, T: Eq> Eq for &'a T { @@ -240,28 +241,28 @@ mod impls { } impl<T: TotalEq> TotalEq for @T {} - // ~ pointers - impl<T:Eq> Eq for ~T { + // box pointers + impl<T:Eq> Eq for Box<T> { #[inline] - fn eq(&self, other: &~T) -> bool { *(*self) == *(*other) } + fn eq(&self, other: &Box<T>) -> bool { *(*self) == *(*other) } #[inline] - fn ne(&self, other: &~T) -> bool { *(*self) != *(*other) } + fn ne(&self, other: &Box<T>) -> bool { *(*self) != *(*other) } } - impl<T:Ord> Ord for ~T { + impl<T:Ord> Ord for Box<T> { #[inline] - fn lt(&self, other: &~T) -> bool { *(*self) < *(*other) } + fn lt(&self, other: &Box<T>) -> bool { *(*self) < *(*other) } #[inline] - fn le(&self, other: &~T) -> bool { *(*self) <= *(*other) } + fn le(&self, other: &Box<T>) -> bool { *(*self) <= *(*other) } #[inline] - fn ge(&self, other: &~T) -> bool { *(*self) >= *(*other) } + fn ge(&self, other: &Box<T>) -> bool { *(*self) >= *(*other) } #[inline] - fn gt(&self, other: &~T) -> bool { *(*self) > *(*other) } + fn gt(&self, other: &Box<T>) -> bool { *(*self) > *(*other) } } - impl<T: TotalOrd> TotalOrd for ~T { + impl<T: TotalOrd> TotalOrd for Box<T> { #[inline] - fn cmp(&self, other: &~T) -> Ordering { (**self).cmp(*other) } + fn cmp(&self, other: &Box<T>) -> Ordering { (**self).cmp(*other) } } - impl<T: TotalEq> TotalEq for ~T {} + impl<T: TotalEq> TotalEq for Box<T> {} } #[cfg(test)] diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 5aef169cd57..53de765b89c 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -27,9 +27,10 @@ #[phase(syntax, link)] #[cfg(test)] extern crate realstd = "std"; #[phase(syntax, link)] #[cfg(test)] extern crate log; -#[cfg(test)] pub use kinds = realcore::kinds; #[cfg(test)] pub use cmp = realcore::cmp; +#[cfg(test)] pub use kinds = realcore::kinds; #[cfg(test)] pub use ops = realcore::ops; +#[cfg(test)] pub use owned = realcore::owned; #[cfg(test)] pub use ty = realcore::ty; #[cfg(not(test))] @@ -73,6 +74,7 @@ pub mod ptr; #[cfg(not(test))] pub mod ops; #[cfg(not(test))] pub mod ty; #[cfg(not(test))] pub mod cmp; +#[cfg(not(test))] pub mod owned; pub mod clone; pub mod default; pub mod container; diff --git a/src/libcore/owned.rs b/src/libcore/owned.rs new file mode 100644 index 00000000000..d5cdd9c39b6 --- /dev/null +++ b/src/libcore/owned.rs @@ -0,0 +1,38 @@ +// 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. + +//! Operations on unique pointer types + +// FIXME: this module should not exist in libcore. It must currently because the +// Box implementation is quite ad-hoc in the compiler. Once there is +// proper support in the compiler this type will be able to be defined in +// its own module. + +/// A value that represents the global exchange heap. This is the default +/// place that the `box` keyword allocates into when no place is supplied. +/// +/// The following two examples are equivalent: +/// +/// let foo = box(HEAP) Bar::new(...); +/// let foo = box Bar::new(...); +#[lang="exchange_heap"] +#[cfg(not(test))] +pub static HEAP: () = (); + +#[cfg(test)] +pub static HEAP: () = (); + +/// A type that represents a uniquely-owned value. +#[lang="owned_box"] +#[cfg(not(test))] +pub struct Box<T>(*T); + +#[cfg(test)] +pub struct Box<T>(*T); |
