Skip to content

Commit 446bc89

Browse files
committed
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`.
2 parents 1500df8 + cdd8a5a commit 446bc89

35 files changed

+44
-7
lines changed

Diff for: src/doc/reference.md

+3
Original file line numberDiff line numberDiff line change
@@ -3196,6 +3196,7 @@ stands for a *single* data field, whereas a wildcard `..` stands for *all* the
31963196
fields of a particular variant. For example:
31973197

31983198
```
3199+
#![feature(box_patterns)]
31993200
#![feature(box_syntax)]
32003201
enum List<X> { Nil, Cons(X, Box<List<X>>) }
32013202
@@ -3259,6 +3260,7 @@ the inside of the match.
32593260
An example of a `match` expression:
32603261

32613262
```
3263+
#![feature(box_patterns)]
32623264
#![feature(box_syntax)]
32633265
# fn process_pair(a: i32, b: i32) { }
32643266
# fn process_ten() { }
@@ -3294,6 +3296,7 @@ Subpatterns can also be bound to variables by the use of the syntax `variable @
32943296
subpattern`. For example:
32953297

32963298
```
3299+
#![feature(box_patterns)]
32973300
#![feature(box_syntax)]
32983301
32993302
enum List { Nil, Cons(uint, Box<List>) }

Diff for: src/libcollections/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#![feature(alloc)]
2626
#![feature(box_syntax)]
27+
#![feature(box_patterns)]
2728
#![feature(core)]
2829
#![feature(hash)]
2930
#![feature(staged_api)]

Diff for: src/librustc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2424
html_root_url = "http://doc.rust-lang.org/nightly/")]
2525

26+
#![feature(box_patterns)]
2627
#![feature(box_syntax)]
2728
#![feature(collections)]
2829
#![feature(core)]

Diff for: src/librustc_trans/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
html_root_url = "http://doc.rust-lang.org/nightly/")]
2525

2626
#![feature(alloc)]
27+
#![feature(box_patterns)]
2728
#![feature(box_syntax)]
2829
#![feature(collections)]
2930
#![feature(core)]

Diff for: src/librustc_typeck/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ This API is completely unstable and subject to change.
7474

7575
#![allow(non_camel_case_types)]
7676

77+
#![feature(box_patterns)]
7778
#![feature(box_syntax)]
7879
#![feature(collections)]
7980
#![feature(core)]

Diff for: src/librustdoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
html_root_url = "http://doc.rust-lang.org/nightly/",
1919
html_playground_url = "http://play.rust-lang.org/")]
2020

21+
#![feature(box_patterns)]
2122
#![feature(box_syntax)]
2223
#![feature(collections)]
2324
#![feature(core)]

Diff for: src/libsyntax/feature_gate.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ static KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
126126

127127
// Allows using #![no_std]
128128
("no_std", "1.0.0", Active),
129+
130+
// Allows using `box` in patterns; RFC 469
131+
("box_patterns", "1.0.0", Active),
129132
];
130133

131134
enum Status {
@@ -427,7 +430,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
427430
ast::ExprBox(..) | ast::ExprUnary(ast::UnOp::UnUniq, _) => {
428431
self.gate_feature("box_syntax",
429432
e.span,
430-
"box expression syntax is experimental in alpha release; \
433+
"box expression syntax is experimental; \
431434
you can call `Box::new` instead.");
432435
}
433436
ast::ExprLit(ref lit) => {
@@ -486,9 +489,9 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
486489
`[0, ..xs, 0]` are experimental")
487490
}
488491
ast::PatBox(..) => {
489-
self.gate_feature("box_syntax",
492+
self.gate_feature("box_patterns",
490493
pattern.span,
491-
"box pattern syntax is experimental in alpha release");
494+
"box pattern syntax is experimental");
492495
}
493496
_ => {}
494497
}

Diff for: src/libsyntax/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2424
html_root_url = "http://doc.rust-lang.org/nightly/")]
2525

26+
#![feature(box_patterns)]
2627
#![feature(box_syntax)]
2728
#![feature(collections)]
2829
#![feature(core)]

Diff for: src/test/compile-fail/borrowck-loan-in-overloaded-op.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(box_patterns)]
1112
#![feature(box_syntax)]
1213

1314
use std::ops::Add;

Diff for: src/test/compile-fail/borrowck-vec-pattern-nesting.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#![feature(advanced_slice_patterns)]
12+
#![feature(box_patterns)]
1213
#![feature(box_syntax)]
1314

1415
fn a() {

Diff for: src/test/compile-fail/destructure-trait-ref.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// The regression test for #15031 to make sure destructuring trait
1212
// reference work properly.
1313

14+
#![feature(box_patterns)]
1415
#![feature(box_syntax)]
1516

1617
trait T {}

Diff for: src/test/compile-fail/feature-gate-box-expr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
fn main() {
1212
use std::boxed::HEAP;
1313

14-
let x = box 'c'; //~ ERROR box expression syntax is experimental in alpha release
14+
let x = box 'c'; //~ ERROR box expression syntax is experimental
1515
println!("x: {}", x);
1616

17-
let x = box () 'c'; //~ ERROR box expression syntax is experimental in alpha release
17+
let x = box () 'c'; //~ ERROR box expression syntax is experimental
1818
println!("x: {}", x);
1919

20-
let x = box (HEAP) 'c'; //~ ERROR box expression syntax is experimental in alpha release
20+
let x = box (HEAP) 'c'; //~ ERROR box expression syntax is experimental
2121
println!("x: {}", x);
2222
}
2323

Diff for: src/test/compile-fail/feature-gate-box-pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
// except according to those terms.
1010

1111
fn main() {
12-
let box x = Box::new('c'); //~ ERROR box pattern syntax is experimental in alpha release
12+
let box x = Box::new('c'); //~ ERROR box pattern syntax is experimental
1313
println!("x: {}", x);
1414
}

Diff for: src/test/compile-fail/issue-12116.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(box_patterns)]
1112
#![feature(box_syntax)]
1213

1314
enum IntList {

Diff for: src/test/compile-fail/issue-3601.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(box_patterns)]
1112
#![feature(box_syntax)]
1213

1314
struct HTMLImageData {

Diff for: src/test/compile-fail/issue-4972.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(box_patterns)]
1112
#![feature(box_syntax)]
1213

1314
trait MyTrait { }

Diff for: src/test/compile-fail/issue-5100.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(box_patterns)]
1112
#![feature(box_syntax)]
1213

1314
enum A { B, C }

Diff for: src/test/compile-fail/moves-based-on-type-block-bad.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// ignore-tidy-linelength
1212

13+
#![feature(box_patterns)]
1314
#![feature(box_syntax)]
1415

1516
struct S {

Diff for: src/test/compile-fail/regions-ref-in-fn-arg.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(box_patterns)]
1112
#![feature(box_syntax)]
1213

1314
fn arg_item(box ref x: Box<isize>) -> &'static isize {

Diff for: src/test/compile-fail/unreachable-arm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// error-pattern:unreachable pattern
1212

13+
#![feature(box_patterns)]
1314
#![feature(box_syntax)]
1415

1516
enum foo { a(Box<foo>, isize), b(usize), }

Diff for: src/test/debuginfo/destructured-fn-argument.rs

+1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@
311311
// lldb-command:continue
312312

313313
#![allow(unused_variables)]
314+
#![feature(box_patterns)]
314315
#![feature(box_syntax)]
315316
#![omit_gdb_pretty_printer_section]
316317

Diff for: src/test/debuginfo/destructured-for-loop-variable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
// lldb-command:continue
154154

155155
#![allow(unused_variables)]
156+
#![feature(box_patterns)]
156157
#![feature(box_syntax)]
157158
#![omit_gdb_pretty_printer_section]
158159

Diff for: src/test/debuginfo/destructured-local.rs

+1
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@
244244

245245

246246
#![allow(unused_variables)]
247+
#![feature(box_patterns)]
247248
#![feature(box_syntax)]
248249
#![omit_gdb_pretty_printer_section]
249250

Diff for: src/test/run-pass/borrowck-macro-interaction-issue-6304.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// Check that we do not ICE when compiling this
1212
// macro, which reuses the expression `$id`
1313

14+
#![feature(box_patterns)]
1415
#![feature(box_syntax)]
1516

1617
struct Foo {

Diff for: src/test/run-pass/cleanup-rvalue-scopes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// statement or end of block, as appropriate given the temporary
1313
// lifetime rules.
1414

15+
#![feature(box_patterns)]
1516
#![feature(box_syntax)]
1617

1718
use std::ops::Drop;

Diff for: src/test/run-pass/func-arg-ref-pattern.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// pattern.
1616

1717
#![allow(unknown_features)]
18+
#![feature(box_patterns)]
1819
#![feature(box_syntax)]
1920

2021
fn getaddr(box ref x: Box<uint>) -> *const uint {

Diff for: src/test/run-pass/issue-11552.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#![allow(unknown_features)]
12+
#![feature(box_patterns)]
1213
#![feature(box_syntax)]
1314

1415
#[derive(Clone)]

Diff for: src/test/run-pass/issue-16774.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#![allow(unknown_features)]
1212
#![feature(box_syntax)]
13+
#![feature(box_patterns)]
1314
#![feature(unboxed_closures)]
1415

1516
use std::ops::{Deref, DerefMut};

Diff for: src/test/run-pass/issue-21033.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10+
#![feature(box_patterns)]
1011
#![feature(box_syntax)]
1112

1213
enum E {

Diff for: src/test/run-pass/issue-6557.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#![allow(unknown_features)]
12+
#![feature(box_patterns)]
1213
#![feature(box_syntax)]
1314

1415
fn foo(box (_x, _y): Box<(int, int)>) {}

Diff for: src/test/run-pass/match-unique-bind.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#![allow(unknown_features)]
12+
#![feature(box_patterns)]
1213
#![feature(box_syntax)]
1314

1415
pub fn main() {

Diff for: src/test/run-pass/regions-dependent-addr-of.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// Issue #3148.
1313

1414
#![allow(unknown_features)]
15+
#![feature(box_patterns)]
1516
#![feature(box_syntax)]
1617

1718
struct A {

Diff for: src/test/run-pass/unique-destructure.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#![allow(unknown_features)]
12+
#![feature(box_patterns)]
1213
#![feature(box_syntax)]
1314

1415
struct Foo { a: int, b: int }

Diff for: src/test/run-pass/unique-pat-2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#![allow(unknown_features)]
12+
#![feature(box_patterns)]
1213
#![feature(box_syntax)]
1314

1415
struct Foo {a: int, b: uint}

Diff for: src/test/run-pass/unique-pat.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#![allow(unknown_features)]
12+
#![feature(box_patterns)]
1213
#![feature(box_syntax)]
1314

1415
fn simple() {

0 commit comments

Comments
 (0)