rollup merge of #23794: brson/slicegate
Conflicts: src/test/run-pass/issue-13027.rs
This commit is contained in:
commit
990202cd0e
@ -2337,9 +2337,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
|
||||
@ -3255,7 +3259,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,
|
||||
|
@ -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"];
|
||||
|
||||
|
@ -39,6 +39,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
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#![feature(debug_builders)]
|
||||
#![feature(unique)]
|
||||
#![feature(step_by)]
|
||||
#![feature(slice_patterns)]
|
||||
#![allow(deprecated)] // rand
|
||||
|
||||
extern crate core;
|
||||
|
@ -43,6 +43,7 @@
|
||||
#![feature(str_char)]
|
||||
#![feature(convert)]
|
||||
#![feature(into_cow)]
|
||||
#![feature(slice_patterns)]
|
||||
#![cfg_attr(test, feature(test))]
|
||||
|
||||
#![allow(trivial_casts)]
|
||||
|
@ -37,6 +37,7 @@
|
||||
#![feature(path_ext)]
|
||||
#![feature(path_relative_from)]
|
||||
#![feature(convert)]
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
extern crate arena;
|
||||
extern crate getopts;
|
||||
|
@ -126,6 +126,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.
|
||||
|
@ -147,6 +147,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)
|
||||
|
||||
@ -628,6 +631,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,
|
||||
|
@ -39,6 +39,7 @@
|
||||
#![feature(str_char)]
|
||||
#![feature(convert)]
|
||||
#![feature(into_cow)]
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
extern crate arena;
|
||||
extern crate fmt_macros;
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#![crate_type="dylib"]
|
||||
#![feature(plugin_registrar, rustc_private)]
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
extern crate syntax;
|
||||
extern crate rustc;
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// Test that immutable pattern bindings cannot be reassigned.
|
||||
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
enum E {
|
||||
Foo(isize)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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];
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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"),
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// compile-flags:-Z verbose
|
||||
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
fn main() {
|
||||
let x = [1,2];
|
||||
let y = match x {
|
||||
|
@ -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 {
|
||||
|
@ -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];
|
||||
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
//
|
||||
|
@ -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 {
|
||||
|
@ -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 () {
|
||||
[()] => { }
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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 }
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -9,6 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(advanced_slice_patterns)]
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
struct Foo {
|
||||
first: bool,
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
@ -13,6 +13,8 @@
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
struct D { x: u8 }
|
||||
|
||||
impl Drop for D { fn drop(&mut self) { } }
|
||||
|
@ -11,6 +11,7 @@
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(advanced_slice_patterns)]
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
struct Foo(isize, isize, isize, isize);
|
||||
struct Bar{a: isize, b: isize, c: isize, d: isize}
|
||||
|
@ -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() -> usize { 1 }
|
||||
|
||||
static CONST: usize = 1;
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
fn main() {
|
||||
let mut x: &[_] = &[1, 2, 3, 4];
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
fn main() {
|
||||
assert_eq!(count_members(&[1, 2, 3, 4]), 4);
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
fn main() {
|
||||
let x: (isize, &[isize]) = (2, &[1, 2]);
|
||||
assert_eq!(match x {
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
fn main() {
|
||||
assert_eq!(match [0u8; 1024] {
|
||||
_ => 42_usize,
|
||||
|
@ -11,6 +11,7 @@
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(advanced_slice_patterns)]
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
use std::ops::Add;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -11,6 +11,7 @@
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(advanced_slice_patterns,)]
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
fn f<T,>(_: T,) {}
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
pub fn main() {
|
||||
let x = [1, 2, 3];
|
||||
match x {
|
||||
|
@ -11,6 +11,7 @@
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(advanced_slice_patterns)]
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
fn a() {
|
||||
let x = [1, 2, 3];
|
||||
|
@ -11,6 +11,7 @@
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(advanced_slice_patterns)]
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
fn foldl<T, U, F>(values: &[T],
|
||||
initial: U,
|
||||
|
@ -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: &[isize] = &[1, 2, 3, 4, 5];
|
||||
|
@ -11,6 +11,7 @@
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(advanced_slice_patterns)]
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
fn a() {
|
||||
let x = [1];
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
struct Foo {
|
||||
string: String
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(slice_patterns)]
|
||||
|
||||
fn main() {
|
||||
let x = [(), ()];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user