Skip to content

Commit 373cbab

Browse files
committed
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
2 parents d11bfba + ae4bcd4 commit 373cbab

File tree

287 files changed

+784
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

287 files changed

+784
-15
lines changed

src/compiletest/compiletest.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
// except according to those terms.
1010

1111
#![crate_type = "bin"]
12-
#![feature(slicing_syntax)]
12+
#![allow(unknown_features)]
13+
#![feature(slicing_syntax, unboxed_closures)]
14+
#![feature(box_syntax)]
1315

1416
#![deny(warnings)]
1517

src/liballoc/boxed.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ pub static HEAP: () = ();
4949
#[stable]
5050
pub struct Box<T>(Unique<T>);
5151

52+
#[unstable]
53+
impl<T> Box<T> {
54+
/// Moves `x` into a freshly allocated box on the global exchange heap.
55+
#[unstable]
56+
pub fn new(x: T) -> Box<T> {
57+
box x
58+
}
59+
}
60+
5261
#[stable]
5362
impl<T: Default> Default for Box<T> {
5463
#[stable]
@@ -186,36 +195,36 @@ impl<T: ?Sized> DerefMut for Box<T> {
186195
mod test {
187196
#[test]
188197
fn test_owned_clone() {
189-
let a = box 5i;
198+
let a = Box::new(5i);
190199
let b: Box<int> = a.clone();
191200
assert!(a == b);
192201
}
193202

194203
#[test]
195204
fn any_move() {
196-
let a = box 8u as Box<Any>;
197-
let b = box Test as Box<Any>;
205+
let a = Box::new(8u) as Box<Any>;
206+
let b = Box::new(Test) as Box<Any>;
198207

199208
match a.downcast::<uint>() {
200-
Ok(a) => { assert!(a == box 8u); }
209+
Ok(a) => { assert!(a == Box::new(8u)); }
201210
Err(..) => panic!()
202211
}
203212
match b.downcast::<Test>() {
204-
Ok(a) => { assert!(a == box Test); }
213+
Ok(a) => { assert!(a == Box::new(Test)); }
205214
Err(..) => panic!()
206215
}
207216

208-
let a = box 8u as Box<Any>;
209-
let b = box Test as Box<Any>;
217+
let a = Box::new(8u) as Box<Any>;
218+
let b = Box::new(Test) as Box<Any>;
210219

211220
assert!(a.downcast::<Box<Test>>().is_err());
212221
assert!(b.downcast::<Box<uint>>().is_err());
213222
}
214223

215224
#[test]
216225
fn test_show() {
217-
let a = box 8u as Box<Any>;
218-
let b = box Test as Box<Any>;
226+
let a = Box::new(8u) as Box<Any>;
227+
let b = Box::new(Test) as Box<Any>;
219228
let a_str = a.to_str();
220229
let b_str = b.to_str();
221230
assert_eq!(a_str, "Box<Any>");
@@ -232,6 +241,6 @@ mod test {
232241
#[test]
233242
fn deref() {
234243
fn homura<T: Deref<Target=i32>>(_: T) { }
235-
homura(box 765i32);
244+
homura(Box::new(765i32));
236245
}
237246
}

src/liballoc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#![no_std]
6868
#![allow(unknown_features)]
6969
#![feature(lang_items, unsafe_destructor)]
70+
#![feature(box_syntax)]
7071

7172
#[macro_use]
7273
extern crate core;

src/libcollections/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#![allow(unknown_features)]
2626
#![feature(unsafe_destructor, slicing_syntax)]
27+
#![feature(box_syntax)]
2728
#![feature(unboxed_closures)]
2829
#![feature(old_impl_check)]
2930
#![no_std]

src/liblog/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@
164164
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
165165
html_root_url = "http://doc.rust-lang.org/nightly/",
166166
html_playground_url = "http://play.rust-lang.org/")]
167+
168+
#![allow(unknown_features)]
167169
#![feature(slicing_syntax)]
170+
#![feature(box_syntax)]
168171
#![deny(missing_docs)]
169172

170173
extern crate regex;

src/libregex/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#![allow(unknown_features)]
2727
#![feature(slicing_syntax)]
28+
#![feature(box_syntax)]
2829
#![deny(missing_docs)]
2930

3031
#[cfg(test)]

src/librustc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#![allow(unknown_features)]
2727
#![feature(quote)]
2828
#![feature(slicing_syntax, unsafe_destructor)]
29+
#![feature(box_syntax)]
2930
#![feature(rustc_diagnostic_macros)]
3031
#![feature(old_impl_check)]
3132

src/librustc_driver/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2424
html_root_url = "http://doc.rust-lang.org/nightly/")]
2525

26+
#![allow(unknown_features)]
2627
#![feature(quote)]
2728
#![feature(slicing_syntax, unsafe_destructor)]
29+
#![feature(box_syntax)]
2830
#![feature(rustc_diagnostic_macros)]
2931

3032
extern crate arena;

src/librustc_llvm/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2323
html_root_url = "http://doc.rust-lang.org/nightly/")]
2424

25+
#![allow(unknown_features)]
2526
#![feature(link_args)]
27+
#![feature(box_syntax)]
2628

2729
extern crate libc;
2830

src/librustc_trans/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2424
html_root_url = "http://doc.rust-lang.org/nightly/")]
2525

26+
#![allow(unknown_features)]
2627
#![feature(quote)]
2728
#![feature(slicing_syntax, unsafe_destructor)]
29+
#![feature(box_syntax)]
2830
#![feature(rustc_diagnostic_macros)]
2931

3032
extern crate arena;

0 commit comments

Comments
 (0)