1
Fork 0

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]
This commit is contained in:
Felix S. Klock II 2015-01-07 15:15:34 +01:00
parent 82af2a1847
commit 4a31aaddb3
14 changed files with 25 additions and 0 deletions

View file

@ -66,6 +66,7 @@
#![no_std] #![no_std]
#![allow(unknown_features)] #![allow(unknown_features)]
#![feature(lang_items, unsafe_destructor)] #![feature(lang_items, unsafe_destructor)]
#![feature(box_syntax)]
#[macro_use] #[macro_use]
extern crate core; extern crate core;

View file

@ -24,6 +24,7 @@
#![allow(unknown_features)] #![allow(unknown_features)]
#![feature(unsafe_destructor, slicing_syntax)] #![feature(unsafe_destructor, slicing_syntax)]
#![feature(old_impl_check)] #![feature(old_impl_check)]
#![feature(box_syntax)]
#![feature(unboxed_closures)] #![feature(unboxed_closures)]
#![no_std] #![no_std]

View file

@ -164,6 +164,7 @@
html_root_url = "http://doc.rust-lang.org/nightly/", html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")] html_playground_url = "http://play.rust-lang.org/")]
#![feature(slicing_syntax)] #![feature(slicing_syntax)]
#![feature(box_syntax)]
#![deny(missing_docs)] #![deny(missing_docs)]
extern crate regex; extern crate regex;

View file

@ -24,6 +24,7 @@
#![allow(unknown_features)] #![allow(unknown_features)]
#![feature(slicing_syntax)] #![feature(slicing_syntax)]
#![feature(box_syntax)]
#![deny(missing_docs)] #![deny(missing_docs)]
#[cfg(test)] #[cfg(test)]

View file

@ -25,6 +25,7 @@
#![allow(unknown_features)] #![allow(unknown_features)]
#![feature(quote)] #![feature(quote)]
#![feature(slicing_syntax, unsafe_destructor)] #![feature(slicing_syntax, unsafe_destructor)]
#![feature(box_syntax)]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]
#![feature(old_impl_check)] #![feature(old_impl_check)]

View file

@ -24,6 +24,7 @@
#![feature(quote)] #![feature(quote)]
#![feature(slicing_syntax, unsafe_destructor)] #![feature(slicing_syntax, unsafe_destructor)]
#![feature(box_syntax)]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]
extern crate arena; extern crate arena;

View file

@ -73,6 +73,7 @@ This API is completely unstable and subject to change.
#![feature(quote)] #![feature(quote)]
#![feature(slicing_syntax, unsafe_destructor)] #![feature(slicing_syntax, unsafe_destructor)]
#![feature(box_syntax)]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]

View file

@ -17,6 +17,7 @@
html_root_url = "http://doc.rust-lang.org/nightly/", html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")] html_playground_url = "http://play.rust-lang.org/")]
#![feature(slicing_syntax)] #![feature(slicing_syntax)]
#![feature(box_syntax)]
extern crate arena; extern crate arena;
extern crate getopts; extern crate getopts;

View file

@ -24,6 +24,7 @@ Core encoding and decoding interfaces.
html_playground_url = "http://play.rust-lang.org/")] html_playground_url = "http://play.rust-lang.org/")]
#![allow(unknown_features)] #![allow(unknown_features)]
#![feature(slicing_syntax)] #![feature(slicing_syntax)]
#![feature(box_syntax)]
#![feature(old_impl_check)] #![feature(old_impl_check)]
#![cfg_attr(stage0, allow(unused_attributes))] #![cfg_attr(stage0, allow(unused_attributes))]

View file

@ -107,6 +107,7 @@
#![feature(linkage, thread_local, asm)] #![feature(linkage, thread_local, asm)]
#![feature(lang_items, unsafe_destructor)] #![feature(lang_items, unsafe_destructor)]
#![feature(slicing_syntax, unboxed_closures)] #![feature(slicing_syntax, unboxed_closures)]
#![feature(box_syntax)]
#![feature(old_impl_check)] #![feature(old_impl_check)]
#![cfg_attr(stage0, allow(unused_attributes))] #![cfg_attr(stage0, allow(unused_attributes))]

View file

@ -70,6 +70,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
("associated_types", Accepted), ("associated_types", Accepted),
("visible_private_types", Active), ("visible_private_types", Active),
("slicing_syntax", Active), ("slicing_syntax", Active),
("box_syntax", Active),
("if_let", Accepted), ("if_let", Accepted),
("while_let", Accepted), ("while_let", Accepted),
@ -343,6 +344,12 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
e.span, e.span,
"range syntax is experimental"); "range syntax is experimental");
} }
ast::ExprBox(..) | ast::ExprUnary(ast::UnOp::UnUniq, _) => {
self.gate_feature("box_syntax",
e.span,
"box expression syntax is experimental in alpha release; \
you can call `Box::new` instead.");
}
_ => {} _ => {}
} }
visit::walk_expr(self, e); visit::walk_expr(self, e);
@ -365,6 +372,11 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
but at the end of a slice (e.g. \ but at the end of a slice (e.g. \
`[0, ..xs, 0]` are experimental") `[0, ..xs, 0]` are experimental")
} }
ast::PatBox(..) => {
self.gate_feature("box_syntax",
pattern.span,
"box pattern syntax is experimental in alpha release");
}
_ => {} _ => {}
} }
visit::walk_pat(self, pattern) visit::walk_pat(self, pattern)

View file

@ -24,6 +24,7 @@
#![allow(unknown_features)] #![allow(unknown_features)]
#![feature(slicing_syntax)] #![feature(slicing_syntax)]
#![feature(box_syntax)]
#![feature(quote, unsafe_destructor)] #![feature(quote, unsafe_destructor)]
extern crate arena; extern crate arena;

View file

@ -49,6 +49,7 @@
#![allow(unknown_features)] #![allow(unknown_features)]
#![feature(slicing_syntax)] #![feature(slicing_syntax)]
#![feature(box_syntax)]
#![deny(missing_docs)] #![deny(missing_docs)]
#[macro_use] extern crate log; #[macro_use] extern crate log;

View file

@ -31,6 +31,7 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")] html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(asm, slicing_syntax)] #![feature(asm, slicing_syntax)]
#![feature(box_syntax)]
extern crate getopts; extern crate getopts;
extern crate regex; extern crate regex;