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

src/doc/reference.md

Lines changed: 3 additions & 0 deletions
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>) }

src/libcollections/lib.rs

Lines changed: 1 addition & 0 deletions
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)]

src/librustc/lib.rs

Lines changed: 1 addition & 0 deletions
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)]

src/librustc_trans/lib.rs

Lines changed: 1 addition & 0 deletions
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)]

src/librustc_typeck/lib.rs

Lines changed: 1 addition & 0 deletions
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)]

src/librustdoc/lib.rs

Lines changed: 1 addition & 0 deletions
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)]

src/libsyntax/feature_gate.rs

Lines changed: 6 additions & 3 deletions
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
}

src/libsyntax/lib.rs

Lines changed: 1 addition & 0 deletions
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)]

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

Lines changed: 1 addition & 0 deletions
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;

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

Lines changed: 1 addition & 0 deletions
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() {

0 commit comments

Comments
 (0)