rollup merge of #20723: pnkfelix/feature-gate-box-syntax

Conflicts:
	src/compiletest/compiletest.rs
	src/libcollections/lib.rs
	src/libserialize/lib.rs
	src/libsyntax/feature_gate.rs
This commit is contained in:
Alex Crichton 2015-01-07 17:42:47 -08:00
commit 373cbab5b0
287 changed files with 784 additions and 15 deletions

View file

@ -49,6 +49,15 @@ pub static HEAP: () = ();
#[stable]
pub struct Box<T>(Unique<T>);
#[unstable]
impl<T> Box<T> {
/// Moves `x` into a freshly allocated box on the global exchange heap.
#[unstable]
pub fn new(x: T) -> Box<T> {
box x
}
}
#[stable]
impl<T: Default> Default for Box<T> {
#[stable]
@ -186,27 +195,27 @@ impl<T: ?Sized> DerefMut for Box<T> {
mod test {
#[test]
fn test_owned_clone() {
let a = box 5i;
let a = Box::new(5i);
let b: Box<int> = a.clone();
assert!(a == b);
}
#[test]
fn any_move() {
let a = box 8u as Box<Any>;
let b = box Test as Box<Any>;
let a = Box::new(8u) as Box<Any>;
let b = Box::new(Test) as Box<Any>;
match a.downcast::<uint>() {
Ok(a) => { assert!(a == box 8u); }
Ok(a) => { assert!(a == Box::new(8u)); }
Err(..) => panic!()
}
match b.downcast::<Test>() {
Ok(a) => { assert!(a == box Test); }
Ok(a) => { assert!(a == Box::new(Test)); }
Err(..) => panic!()
}
let a = box 8u as Box<Any>;
let b = box Test as Box<Any>;
let a = Box::new(8u) as Box<Any>;
let b = Box::new(Test) as Box<Any>;
assert!(a.downcast::<Box<Test>>().is_err());
assert!(b.downcast::<Box<uint>>().is_err());
@ -214,8 +223,8 @@ mod test {
#[test]
fn test_show() {
let a = box 8u as Box<Any>;
let b = box Test as Box<Any>;
let a = Box::new(8u) as Box<Any>;
let b = Box::new(Test) as Box<Any>;
let a_str = a.to_str();
let b_str = b.to_str();
assert_eq!(a_str, "Box<Any>");
@ -232,6 +241,6 @@ mod test {
#[test]
fn deref() {
fn homura<T: Deref<Target=i32>>(_: T) { }
homura(box 765i32);
homura(Box::new(765i32));
}
}