Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature gate box patterns #22175

Merged
merged 7 commits into from
Feb 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>>) }

Expand Down Expand Up @@ -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() { }
Expand Down Expand Up @@ -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>) }
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#![feature(alloc)]
#![feature(box_syntax)]
#![feature(box_patterns)]
#![feature(core)]
#![feature(hash)]
#![feature(staged_api)]
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 1 addition & 0 deletions src/librustc_trans/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 1 addition & 0 deletions src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
9 changes: 6 additions & 3 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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");
}
_ => {}
}
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/borrowck-loan-in-overloaded-op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/borrowck-vec-pattern-nesting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

#![feature(advanced_slice_patterns)]
#![feature(box_patterns)]
#![feature(box_syntax)]

fn a() {
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/destructure-trait-ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
6 changes: 3 additions & 3 deletions src/test/compile-fail/feature-gate-box-expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

2 changes: 1 addition & 1 deletion src/test/compile-fail/feature-gate-box-pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-12116.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-3601.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-4972.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-5100.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/moves-based-on-type-block-bad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

// ignore-tidy-linelength

#![feature(box_patterns)]
#![feature(box_syntax)]

struct S {
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/regions-ref-in-fn-arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/unreachable-arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

// error-pattern:unreachable pattern

#![feature(box_patterns)]
#![feature(box_syntax)]

enum foo { a(Box<foo>, isize), b(usize), }
Expand Down
1 change: 1 addition & 0 deletions src/test/debuginfo/destructured-fn-argument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@
// lldb-command:continue

#![allow(unused_variables)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]

Expand Down
1 change: 1 addition & 0 deletions src/test/debuginfo/destructured-for-loop-variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
// lldb-command:continue

#![allow(unused_variables)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]

Expand Down
1 change: 1 addition & 0 deletions src/test/debuginfo/destructured-local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@


#![allow(unused_variables)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]

Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/borrowck-macro-interaction-issue-6304.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/cleanup-rvalue-scopes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/func-arg-ref-pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// pattern.

#![allow(unknown_features)]
#![feature(box_patterns)]
#![feature(box_syntax)]

fn getaddr(box ref x: Box<uint>) -> *const uint {
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/issue-11552.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

#![allow(unknown_features)]
#![feature(box_patterns)]
#![feature(box_syntax)]

#[derive(Clone)]
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/issue-16774.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#![allow(unknown_features)]
#![feature(box_syntax)]
#![feature(box_patterns)]
#![feature(unboxed_closures)]

use std::ops::{Deref, DerefMut};
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/issue-21033.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/issue-6557.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)>) {}
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/match-unique-bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

#![allow(unknown_features)]
#![feature(box_patterns)]
#![feature(box_syntax)]

pub fn main() {
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/regions-dependent-addr-of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// Issue #3148.

#![allow(unknown_features)]
#![feature(box_patterns)]
#![feature(box_syntax)]

struct A {
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/unique-destructure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

#![allow(unknown_features)]
#![feature(box_patterns)]
#![feature(box_syntax)]

struct Foo { a: int, b: int }
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/unique-pat-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

#![allow(unknown_features)]
#![feature(box_patterns)]
#![feature(box_syntax)]

struct Foo {a: int, b: uint}
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/unique-pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

#![allow(unknown_features)]
#![feature(box_patterns)]
#![feature(box_syntax)]

fn simple() {
Expand Down