Skip to content

Commit 4a31aad

Browse files
committed
Added box_syntax feature gate; added to std and rustc crates for bootstrap.
To avoid using the feauture, change uses of `box <expr>` to `Box::new(<expr>)` alternative, as noted by the feature gate message. (Note that box patterns have no analogous trivial replacement, at least not in general; you need to revise the code to do a partial match, deref, and then the rest of the match.) [breaking-change]
1 parent 82af2a1 commit 4a31aad

File tree

14 files changed

+25
-0
lines changed

14 files changed

+25
-0
lines changed

src/liballoc/lib.rs

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

7071
#[macro_use]
7172
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
#![allow(unknown_features)]
2525
#![feature(unsafe_destructor, slicing_syntax)]
2626
#![feature(old_impl_check)]
27+
#![feature(box_syntax)]
2728
#![feature(unboxed_closures)]
2829
#![no_std]
2930

src/liblog/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
html_root_url = "http://doc.rust-lang.org/nightly/",
165165
html_playground_url = "http://play.rust-lang.org/")]
166166
#![feature(slicing_syntax)]
167+
#![feature(box_syntax)]
167168
#![deny(missing_docs)]
168169

169170
extern crate regex;

src/libregex/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(slicing_syntax)]
27+
#![feature(box_syntax)]
2728
#![deny(missing_docs)]
2829

2930
#[cfg(test)]

src/librustc/lib.rs

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

src/librustc_trans/lib.rs

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

2525
#![feature(quote)]
2626
#![feature(slicing_syntax, unsafe_destructor)]
27+
#![feature(box_syntax)]
2728
#![feature(rustc_diagnostic_macros)]
2829

2930
extern crate arena;

src/librustc_typeck/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ This API is completely unstable and subject to change.
7373

7474
#![feature(quote)]
7575
#![feature(slicing_syntax, unsafe_destructor)]
76+
#![feature(box_syntax)]
7677
#![feature(rustc_diagnostic_macros)]
7778
#![allow(non_camel_case_types)]
7879

src/librustdoc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
html_root_url = "http://doc.rust-lang.org/nightly/",
1818
html_playground_url = "http://play.rust-lang.org/")]
1919
#![feature(slicing_syntax)]
20+
#![feature(box_syntax)]
2021

2122
extern crate arena;
2223
extern crate getopts;

src/libserialize/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Core encoding and decoding interfaces.
2424
html_playground_url = "http://play.rust-lang.org/")]
2525
#![allow(unknown_features)]
2626
#![feature(slicing_syntax)]
27+
#![feature(box_syntax)]
2728
#![feature(old_impl_check)]
2829
#![cfg_attr(stage0, allow(unused_attributes))]
2930

src/libstd/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
#![feature(linkage, thread_local, asm)]
108108
#![feature(lang_items, unsafe_destructor)]
109109
#![feature(slicing_syntax, unboxed_closures)]
110+
#![feature(box_syntax)]
110111
#![feature(old_impl_check)]
111112
#![cfg_attr(stage0, allow(unused_attributes))]
112113

src/libsyntax/feature_gate.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
7070
("associated_types", Accepted),
7171
("visible_private_types", Active),
7272
("slicing_syntax", Active),
73+
("box_syntax", Active),
7374

7475
("if_let", Accepted),
7576
("while_let", Accepted),
@@ -343,6 +344,12 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
343344
e.span,
344345
"range syntax is experimental");
345346
}
347+
ast::ExprBox(..) | ast::ExprUnary(ast::UnOp::UnUniq, _) => {
348+
self.gate_feature("box_syntax",
349+
e.span,
350+
"box expression syntax is experimental in alpha release; \
351+
you can call `Box::new` instead.");
352+
}
346353
_ => {}
347354
}
348355
visit::walk_expr(self, e);
@@ -365,6 +372,11 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
365372
but at the end of a slice (e.g. \
366373
`[0, ..xs, 0]` are experimental")
367374
}
375+
ast::PatBox(..) => {
376+
self.gate_feature("box_syntax",
377+
pattern.span,
378+
"box pattern syntax is experimental in alpha release");
379+
}
368380
_ => {}
369381
}
370382
visit::walk_pat(self, pattern)

src/libsyntax/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(slicing_syntax)]
27+
#![feature(box_syntax)]
2728
#![feature(quote, unsafe_destructor)]
2829

2930
extern crate arena;

src/libterm/lib.rs

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

5050
#![allow(unknown_features)]
5151
#![feature(slicing_syntax)]
52+
#![feature(box_syntax)]
5253
#![deny(missing_docs)]
5354

5455
#[macro_use] extern crate log;

src/libtest/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
3232
html_root_url = "http://doc.rust-lang.org/nightly/")]
3333
#![feature(asm, slicing_syntax)]
34+
#![feature(box_syntax)]
3435

3536
extern crate getopts;
3637
extern crate regex;

0 commit comments

Comments
 (0)