Feature gate *all* slice patterns. #23121

Until some backwards-compatibility hazards are fixed in #23121,
these need to be unstable.

[breaking-change]
This commit is contained in:
Brian Anderson 2015-03-26 18:34:27 -07:00
parent 199bdcfeff
commit 1639e51f6e
51 changed files with 93 additions and 3 deletions

View File

@ -2408,9 +2408,13 @@ considered off, and using the features will result in a compiler error.
The currently implemented features of the reference compiler are:
* `advanced_slice_patterns` - see the [match expressions](#match-expressions)
* `advanced_slice_patterns` - See the [match expressions](#match-expressions)
section for discussion; the exact semantics of
slice patterns are subject to change.
slice patterns are subject to change, so some types
are still unstable.
* `slice_patterns` - OK, actually, slice patterns are just scary and
completely unstable.
* `asm` - The `asm!` macro provides a means for inline assembly. This is often
useful, but the exact syntax for this feature along with its
@ -3329,7 +3333,7 @@ array, like `[.., 42, ..]`. If preceded by a variable name, it will bind the
corresponding slice to the variable. Example:
```
# #![feature(advanced_slice_patterns)]
# #![feature(advanced_slice_patterns, slice_patterns)]
fn is_symmetric(list: &[u32]) -> bool {
match list {
[] | [_] => true,

View File

@ -177,6 +177,7 @@ match origin {
If you want to match against a slice or array, you can use `&`:
```{rust}
# #![feature(slice_patterns)]
fn main() {
let v = vec!["match_this", "1"];

View File

@ -40,6 +40,7 @@
#![feature(step_by)]
#![feature(str_char)]
#![feature(convert)]
#![feature(slice_patterns)]
#![cfg_attr(test, feature(rand, rustc_private, test, hash, collections))]
#![cfg_attr(test, allow(deprecated))] // rand

View File

@ -26,6 +26,7 @@
#![feature(debug_builders)]
#![feature(unique)]
#![feature(step_by)]
#![feature(slice_patterns)]
#![allow(deprecated)] // rand
extern crate core;

View File

@ -45,6 +45,7 @@
#![feature(str_char)]
#![feature(convert)]
#![feature(into_cow)]
#![feature(slice_patterns)]
#![cfg_attr(test, feature(test))]
#![allow(trivial_casts)]

View File

@ -39,6 +39,7 @@
#![feature(path_ext)]
#![feature(path_relative_from)]
#![feature(convert)]
#![feature(slice_patterns)]
extern crate arena;
extern crate getopts;

View File

@ -129,6 +129,7 @@
#![feature(allow_internal_unstable)]
#![feature(str_char)]
#![feature(into_cow)]
#![feature(slice_patterns)]
#![cfg_attr(test, feature(test, rustc_private, std_misc))]
// Don't link to std. We are std.

View File

@ -153,6 +153,9 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
// below (it has to be checked before expansion possibly makes
// macros disappear).
("allow_internal_unstable", "1.0.0", Active),
// #23121. Array patterns have some hazards yet.
("slice_patterns", "1.0.0", Active),
];
// (changing above list without updating src/doc/reference.md makes @cmr sad)
@ -694,6 +697,11 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
but at the end of a slice (e.g. \
`[0, ..xs, 0]` are experimental")
}
ast::PatVec(..) => {
self.gate_feature("slice_patterns",
pattern.span,
"slice pattern syntax is experimental");
}
ast::PatBox(..) => {
self.gate_feature("box_patterns",
pattern.span,

View File

@ -41,6 +41,7 @@
#![feature(str_char)]
#![feature(convert)]
#![feature(into_cow)]
#![feature(slice_patterns)]
extern crate arena;
extern crate fmt_macros;

View File

@ -12,6 +12,7 @@
#![crate_type="dylib"]
#![feature(plugin_registrar, rustc_private)]
#![feature(slice_patterns)]
extern crate syntax;
extern crate rustc;

View File

@ -10,6 +10,8 @@
// Test that immutable pattern bindings cannot be reassigned.
#![feature(slice_patterns)]
enum E {
Foo(isize)
}

View File

@ -10,6 +10,8 @@
// Test that we do not permit moves from &[] matched by a vec pattern.
#![feature(slice_patterns)]
#[derive(Clone, Debug)]
struct Foo {
string: String

View File

@ -9,6 +9,7 @@
// except according to those terms.
#![feature(advanced_slice_patterns)]
#![feature(slice_patterns)]
fn a<'a>() -> &'a [isize] {
let vec = vec!(1, 2, 3, 4);

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
fn a() {
let mut v = vec!(1, 2, 3);
let vb: &mut [isize] = &mut v;

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
fn main() {
let mut a = [1, 2, 3, 4];
let t = match a {

View File

@ -11,6 +11,7 @@
#![feature(advanced_slice_patterns)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(slice_patterns)]
fn a() {
let mut vec = [box 1, box 2, box 3];

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
fn a<'a>() -> &'a isize {
let vec = vec!(1, 2, 3, 4);
let vec: &[isize] = &vec; //~ ERROR `vec` does not live long enough

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
fn main() {
let x = [ 1, 2, 3, 4, 5 ];
match x {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
fn main() {
let sl = vec![1,2,3];
let v: isize = match &*sl {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) {
match (l1, l2) {
([], []) => println!("both empty"),

View File

@ -10,6 +10,8 @@
// compile-flags:-Z verbose
#![feature(slice_patterns)]
fn main() {
let x = [1,2];
let y = match x {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
fn main() {
let x = [1,2];
let y = match x {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
fn main() {
let values: Vec<u8> = vec![1,2,3,4,5,6,7,8];

View File

@ -9,6 +9,7 @@
// except according to those terms.
#![feature(rustc_attrs)]
#![feature(slice_patterns)]
#![allow(dead_code)]
// Matching against NaN should result in a warning

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
// The arity of `ref x` is always 1. If the pattern is compared to some non-structural type whose
// arity is always 0, an ICE occurs.
//

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
fn a() {
let v = [1, 2, 3];
match v {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
fn main() {
match () {
[()] => { }

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
fn main() {
match "foo".to_string() {
['f', 'o', ..] => {} //~ ERROR mismatched types

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
fn main() {
let x: Vec<(isize, isize)> = Vec::new();

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
enum t { a(u), b }
enum u { c, d }

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
enum t { a, b, }
fn main() {

View File

@ -9,6 +9,7 @@
// except according to those terms.
#![feature(advanced_slice_patterns)]
#![feature(slice_patterns)]
struct Foo {
first: bool,

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
fn assert_static<T: 'static>(_t: T) {}
fn main() {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
pub fn pat_vec_7() {
match [7, 77, 777, 7777] {
[x, y, ..] => x + y

View File

@ -13,6 +13,8 @@
// pretty-expanded FIXME #23616
#![feature(slice_patterns)]
struct D { x: u8 }
impl Drop for D { fn drop(&mut self) { } }

View File

@ -11,6 +11,7 @@
// pretty-expanded FIXME #23616
#![feature(advanced_slice_patterns)]
#![feature(slice_patterns)]
struct Foo(int, int, int, int);
struct Bar{a: int, b: int, c: int, d: int}

View File

@ -13,6 +13,8 @@
// Tests that match expression handles overlapped literal and range
// properly in the presence of guard function.
#![feature(slice_patterns)]
fn val() -> uint { 1 }
static CONST: uint = 1;

View File

@ -10,6 +10,8 @@
// pretty-expanded FIXME #23616
#![feature(slice_patterns)]
fn main() {
let mut x: &[_] = &[1, 2, 3, 4];

View File

@ -10,6 +10,8 @@
// pretty-expanded FIXME #23616
#![feature(slice_patterns)]
fn main() {
assert_eq!(count_members(&[1, 2, 3, 4]), 4);
}

View File

@ -10,6 +10,8 @@
// pretty-expanded FIXME #23616
#![feature(slice_patterns)]
fn main() {
let x: (int, &[int]) = (2, &[1, 2]);
assert_eq!(match x {

View File

@ -10,6 +10,8 @@
// pretty-expanded FIXME #23616
#![feature(slice_patterns)]
fn main() {
assert_eq!(match [0u8; 1024] {
_ => 42_usize,

View File

@ -11,6 +11,7 @@
// pretty-expanded FIXME #23616
#![feature(advanced_slice_patterns)]
#![feature(slice_patterns)]
use std::ops::Add;

View File

@ -11,6 +11,7 @@
// pretty-expanded FIXME #23616
#![feature(advanced_slice_patterns)]
#![feature(slice_patterns)]
fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) -> &'static str {
match (l1, l2) {

View File

@ -11,6 +11,7 @@
// pretty-expanded FIXME #23616
#![feature(advanced_slice_patterns,)]
#![feature(slice_patterns)]
fn f<T,>(_: T,) {}

View File

@ -10,6 +10,8 @@
// pretty-expanded FIXME #23616
#![feature(slice_patterns)]
pub fn main() {
let x = [1, 2, 3];
match x {

View File

@ -11,6 +11,7 @@
// pretty-expanded FIXME #23616
#![feature(advanced_slice_patterns)]
#![feature(slice_patterns)]
fn a() {
let x = [1, 2, 3];

View File

@ -11,6 +11,7 @@
// pretty-expanded FIXME #23616
#![feature(advanced_slice_patterns)]
#![feature(slice_patterns)]
fn foldl<T, U, F>(values: &[T],
initial: U,

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(slice_patterns)]
pub fn main() {
let x = &[1, 2, 3, 4, 5];
let x: &[int] = &[1, 2, 3, 4, 5];

View File

@ -11,6 +11,7 @@
// pretty-expanded FIXME #23616
#![feature(advanced_slice_patterns)]
#![feature(slice_patterns)]
fn a() {
let x = [1];

View File

@ -11,6 +11,8 @@
// pretty-expanded FIXME #23616
#![feature(slice_patterns)]
struct Foo {
string: String
}

View File

@ -10,6 +10,8 @@
// pretty-expanded FIXME #23616
#![feature(slice_patterns)]
fn main() {
let x = [(), ()];