Auto merge of #22175 - pnkfelix:featuregate-boxpat-rfc469, r=nikomatsakis

Feature gate `box` patterns.

Note that this adds a new feature gate, `box_patterns` specific to e.g. `let box i = ...`, while leaving  `box` expressions (alone) still guarded via the preexisting `box_syntax`.
This commit is contained in:
bors 2015-02-11 15:00:35 +00:00
commit 446bc899b2
35 changed files with 44 additions and 7 deletions

View File

@ -3196,6 +3196,7 @@ stands for a *single* data field, whereas a wildcard `..` stands for *all* the
fields of a particular variant. For example:
```
#![feature(box_patterns)]
#![feature(box_syntax)]
enum List<X> { Nil, Cons(X, Box<List<X>>) }
@ -3259,6 +3260,7 @@ the inside of the match.
An example of a `match` expression:
```
#![feature(box_patterns)]
#![feature(box_syntax)]
# fn process_pair(a: i32, b: i32) { }
# fn process_ten() { }
@ -3294,6 +3296,7 @@ Subpatterns can also be bound to variables by the use of the syntax `variable @
subpattern`. For example:
```
#![feature(box_patterns)]
#![feature(box_syntax)]
enum List { Nil, Cons(uint, Box<List>) }

View File

@ -24,6 +24,7 @@
#![feature(alloc)]
#![feature(box_syntax)]
#![feature(box_patterns)]
#![feature(core)]
#![feature(hash)]
#![feature(staged_api)]

View File

@ -23,6 +23,7 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]

View File

@ -24,6 +24,7 @@
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(alloc)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]

View File

@ -74,6 +74,7 @@ This API is completely unstable and subject to change.
#![allow(non_camel_case_types)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]

View File

@ -18,6 +18,7 @@
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]

View File

@ -126,6 +126,9 @@ static KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
// Allows using #![no_std]
("no_std", "1.0.0", Active),
// Allows using `box` in patterns; RFC 469
("box_patterns", "1.0.0", Active),
];
enum Status {
@ -427,7 +430,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
ast::ExprBox(..) | ast::ExprUnary(ast::UnOp::UnUniq, _) => {
self.gate_feature("box_syntax",
e.span,
"box expression syntax is experimental in alpha release; \
"box expression syntax is experimental; \
you can call `Box::new` instead.");
}
ast::ExprLit(ref lit) => {
@ -486,9 +489,9 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
`[0, ..xs, 0]` are experimental")
}
ast::PatBox(..) => {
self.gate_feature("box_syntax",
self.gate_feature("box_patterns",
pattern.span,
"box pattern syntax is experimental in alpha release");
"box pattern syntax is experimental");
}
_ => {}
}

View File

@ -23,6 +23,7 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_patterns)]
#![feature(box_syntax)]
use std::ops::Add;

View File

@ -9,6 +9,7 @@
// except according to those terms.
#![feature(advanced_slice_patterns)]
#![feature(box_patterns)]
#![feature(box_syntax)]
fn a() {

View File

@ -11,6 +11,7 @@
// The regression test for #15031 to make sure destructuring trait
// reference work properly.
#![feature(box_patterns)]
#![feature(box_syntax)]
trait T {}

View File

@ -11,13 +11,13 @@
fn main() {
use std::boxed::HEAP;
let x = box 'c'; //~ ERROR box expression syntax is experimental in alpha release
let x = box 'c'; //~ ERROR box expression syntax is experimental
println!("x: {}", x);
let x = box () 'c'; //~ ERROR box expression syntax is experimental in alpha release
let x = box () 'c'; //~ ERROR box expression syntax is experimental
println!("x: {}", x);
let x = box (HEAP) 'c'; //~ ERROR box expression syntax is experimental in alpha release
let x = box (HEAP) 'c'; //~ ERROR box expression syntax is experimental
println!("x: {}", x);
}

View File

@ -9,6 +9,6 @@
// except according to those terms.
fn main() {
let box x = Box::new('c'); //~ ERROR box pattern syntax is experimental in alpha release
let box x = Box::new('c'); //~ ERROR box pattern syntax is experimental
println!("x: {}", x);
}

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_patterns)]
#![feature(box_syntax)]
enum IntList {

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_patterns)]
#![feature(box_syntax)]
struct HTMLImageData {

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_patterns)]
#![feature(box_syntax)]
trait MyTrait { }

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_patterns)]
#![feature(box_syntax)]
enum A { B, C }

View File

@ -10,6 +10,7 @@
// ignore-tidy-linelength
#![feature(box_patterns)]
#![feature(box_syntax)]
struct S {

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(box_patterns)]
#![feature(box_syntax)]
fn arg_item(box ref x: Box<isize>) -> &'static isize {

View File

@ -10,6 +10,7 @@
// error-pattern:unreachable pattern
#![feature(box_patterns)]
#![feature(box_syntax)]
enum foo { a(Box<foo>, isize), b(usize), }

View File

@ -311,6 +311,7 @@
// lldb-command:continue
#![allow(unused_variables)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]

View File

@ -153,6 +153,7 @@
// lldb-command:continue
#![allow(unused_variables)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]

View File

@ -244,6 +244,7 @@
#![allow(unused_variables)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]

View File

@ -11,6 +11,7 @@
// Check that we do not ICE when compiling this
// macro, which reuses the expression `$id`
#![feature(box_patterns)]
#![feature(box_syntax)]
struct Foo {

View File

@ -12,6 +12,7 @@
// statement or end of block, as appropriate given the temporary
// lifetime rules.
#![feature(box_patterns)]
#![feature(box_syntax)]
use std::ops::Drop;

View File

@ -15,6 +15,7 @@
// pattern.
#![allow(unknown_features)]
#![feature(box_patterns)]
#![feature(box_syntax)]
fn getaddr(box ref x: Box<uint>) -> *const uint {

View File

@ -9,6 +9,7 @@
// except according to those terms.
#![allow(unknown_features)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#[derive(Clone)]

View File

@ -10,6 +10,7 @@
#![allow(unknown_features)]
#![feature(box_syntax)]
#![feature(box_patterns)]
#![feature(unboxed_closures)]
use std::ops::{Deref, DerefMut};

View File

@ -7,6 +7,7 @@
// <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.
#![feature(box_patterns)]
#![feature(box_syntax)]
enum E {

View File

@ -9,6 +9,7 @@
// except according to those terms.
#![allow(unknown_features)]
#![feature(box_patterns)]
#![feature(box_syntax)]
fn foo(box (_x, _y): Box<(int, int)>) {}

View File

@ -9,6 +9,7 @@
// except according to those terms.
#![allow(unknown_features)]
#![feature(box_patterns)]
#![feature(box_syntax)]
pub fn main() {

View File

@ -12,6 +12,7 @@
// Issue #3148.
#![allow(unknown_features)]
#![feature(box_patterns)]
#![feature(box_syntax)]
struct A {

View File

@ -9,6 +9,7 @@
// except according to those terms.
#![allow(unknown_features)]
#![feature(box_patterns)]
#![feature(box_syntax)]
struct Foo { a: int, b: int }

View File

@ -9,6 +9,7 @@
// except according to those terms.
#![allow(unknown_features)]
#![feature(box_patterns)]
#![feature(box_syntax)]
struct Foo {a: int, b: uint}

View File

@ -9,6 +9,7 @@
// except according to those terms.
#![allow(unknown_features)]
#![feature(box_patterns)]
#![feature(box_syntax)]
fn simple() {