1
Fork 0

--bless tests due to new subslice syntax.

This commit is contained in:
Mazdak Farrokhzad 2019-07-08 01:58:28 +02:00
parent 75da43dc87
commit 91c8b53f45
14 changed files with 95 additions and 56 deletions

View file

@ -192,8 +192,8 @@ error[E0503]: cannot use `v[..]` because it was mutably borrowed
LL | let x = &mut v;
| ------ borrow of `v` occurs here
LL | match v {
LL | &[x..] => println!("{:?}", x),
| ^ use of borrowed `v`
LL | &[x @ ..] => println!("{:?}", x),
| ^^^^^^ use of borrowed `v`
...
LL | drop(x);
| - borrow later used here
@ -204,8 +204,8 @@ error[E0503]: cannot use `v[..]` because it was mutably borrowed
LL | let x = &mut v;
| ------ borrow of `v` occurs here
...
LL | &[_, x..] => println!("{:?}", x),
| ^ use of borrowed `v`
LL | &[_, x @ ..] => println!("{:?}", x),
| ^^^^^^ use of borrowed `v`
...
LL | drop(x);
| - borrow later used here
@ -216,8 +216,8 @@ error[E0503]: cannot use `v[..]` because it was mutably borrowed
LL | let x = &mut v;
| ------ borrow of `v` occurs here
...
LL | &[x.., _] => println!("{:?}", x),
| ^ use of borrowed `v`
LL | &[x @ .., _] => println!("{:?}", x),
| ^^^^^^ use of borrowed `v`
...
LL | drop(x);
| - borrow later used here
@ -228,8 +228,8 @@ error[E0503]: cannot use `v[..]` because it was mutably borrowed
LL | let x = &mut v;
| ------ borrow of `v` occurs here
...
LL | &[_, x.., _] => println!("{:?}", x),
| ^ use of borrowed `v`
LL | &[_, x @ .., _] => println!("{:?}", x),
| ^^^^^^ use of borrowed `v`
...
LL | drop(x);
| - borrow later used here

View file

@ -13,8 +13,8 @@ error[E0382]: use of moved value: `a[..]`
|
LL | let [_x, _] = a;
| -- value moved here
LL | let [_y..] = a;
| ^^ value used here after move
LL | let [_y @ ..] = a;
| ^^^^^^^ value used here after move
|
= note: move occurs because `a[..]` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait

View file

@ -89,8 +89,8 @@ error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as im
|
LL | if let [ref first, ref second, ..] = *s {
| ---------- immutable borrow occurs here
LL | if let [_, ref mut tail..] = *s {
| ^^^^^^^^^^^^ mutable borrow occurs here
LL | if let [_, ref mut tail @ ..] = *s {
| ^^^^^^^^^^^^^^^^^ mutable borrow occurs here
LL | nop(&[first, second]);
| ------ immutable borrow later used here
@ -99,18 +99,18 @@ error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as im
|
LL | if let [.., ref second, ref first] = *s {
| ---------- immutable borrow occurs here
LL | if let [ref mut tail.., _] = *s {
| ^^^^^^^^^^^^ mutable borrow occurs here
LL | if let [ref mut tail @ .., _] = *s {
| ^^^^^^^^^^^^^^^^^ mutable borrow occurs here
LL | nop(&[first, second]);
| ------ immutable borrow later used here
error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-slice-pattern-element-loan.rs:109:17
|
LL | if let [_, _, _, ref s1..] = *s {
| ------ immutable borrow occurs here
LL | if let [ref mut s2.., _, _, _] = *s {
| ^^^^^^^^^^ mutable borrow occurs here
LL | if let [_, _, _, ref s1 @ ..] = *s {
| ----------- immutable borrow occurs here
LL | if let [ref mut s2 @ .., _, _, _] = *s {
| ^^^^^^^^^^^^^^^ mutable borrow occurs here
LL | nop_subslice(s1);
| -- immutable borrow later used here

View file

@ -1,8 +1,8 @@
error[E0506]: cannot assign to `a[_]` because it is borrowed
--> $DIR/borrowck-vec-pattern-move-tail.rs:12:5
|
LL | [1, 2, ref tail..] => tail,
| -------- borrow of `a[_]` occurs here
LL | [1, 2, ref tail @ ..] => tail,
| ------------- borrow of `a[_]` occurs here
...
LL | a[2] = 0;
| ^^^^^^^^ assignment to borrowed `a[_]` occurs here

View file

@ -13,8 +13,8 @@ LL | _a.use_ref();
error[E0506]: cannot assign to `vec[_]` because it is borrowed
--> $DIR/borrowck-vec-pattern-nesting.rs:24:13
|
LL | &mut [ref _b..] => {
| ------ borrow of `vec[_]` occurs here
LL | &mut [ref _b @ ..] => {
| ----------- borrow of `vec[_]` occurs here
LL |
LL | vec[0] = box 4;
| ^^^^^^ assignment to borrowed `vec[_]` occurs here

View file

@ -1,8 +1,8 @@
error[E0528]: pattern requires at least 3 elements but array has 2
--> $DIR/E0528.rs:6:10
|
LL | &[a, b, c, rest..] => {
| ^^^^^^^^^^^^^^^^^ pattern cannot match array of 2 elements
LL | &[a, b, c, rest @ ..] => {
| ^^^^^^^^^^^^^^^^^^^^ pattern cannot match array of 2 elements
error: aborting due to previous error

View file

@ -3,15 +3,15 @@
fn main() {
let x = [1, 2, 3, 4, 5];
match x {
[1, 2, ..] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized
[1, .., 5] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized
[.., 4, 5] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized
[1, 2, ..] => {} //~ ERROR subslice patterns are unstable
[1, .., 5] => {} //~ ERROR subslice patterns are unstable
[.., 4, 5] => {} //~ ERROR subslice patterns are unstable
}
let x = [ 1, 2, 3, 4, 5 ];
match x {
[ xs @ .., 4, 5 ] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized
[ 1, xs @ .., 5 ] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized
[ 1, 2, xs @ .. ] => {} //~ ERROR syntax for subslices in slice patterns is not yet stabilized
[ xs @ .., 4, 5 ] => {} //~ ERROR subslice patterns are unstable
[ 1, xs @ .., 5 ] => {} //~ ERROR subslice patterns are unstable
[ 1, 2, xs @ .. ] => {} //~ ERROR subslice patterns are unstable
}
}

View file

@ -1,4 +1,4 @@
error[E0658]: syntax for subslices in slice patterns is not yet stabilized
error[E0658]: subslice patterns are unstable
--> $DIR/feature-gate-slice-patterns.rs:6:16
|
LL | [1, 2, ..] => {}
@ -7,7 +7,7 @@ LL | [1, 2, ..] => {}
= note: for more information, see https://github.com/rust-lang/rust/issues/62254
= help: add `#![feature(slice_patterns)]` to the crate attributes to enable
error[E0658]: syntax for subslices in slice patterns is not yet stabilized
error[E0658]: subslice patterns are unstable
--> $DIR/feature-gate-slice-patterns.rs:7:13
|
LL | [1, .., 5] => {}
@ -16,7 +16,7 @@ LL | [1, .., 5] => {}
= note: for more information, see https://github.com/rust-lang/rust/issues/62254
= help: add `#![feature(slice_patterns)]` to the crate attributes to enable
error[E0658]: syntax for subslices in slice patterns is not yet stabilized
error[E0658]: subslice patterns are unstable
--> $DIR/feature-gate-slice-patterns.rs:8:10
|
LL | [.., 4, 5] => {}
@ -25,29 +25,29 @@ LL | [.., 4, 5] => {}
= note: for more information, see https://github.com/rust-lang/rust/issues/62254
= help: add `#![feature(slice_patterns)]` to the crate attributes to enable
error[E0658]: syntax for subslices in slice patterns is not yet stabilized
error[E0658]: subslice patterns are unstable
--> $DIR/feature-gate-slice-patterns.rs:13:11
|
LL | [ xs.., 4, 5 ] => {}
| ^^
LL | [ xs @ .., 4, 5 ] => {}
| ^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/62254
= help: add `#![feature(slice_patterns)]` to the crate attributes to enable
error[E0658]: syntax for subslices in slice patterns is not yet stabilized
error[E0658]: subslice patterns are unstable
--> $DIR/feature-gate-slice-patterns.rs:14:14
|
LL | [ 1, xs.., 5 ] => {}
| ^^
LL | [ 1, xs @ .., 5 ] => {}
| ^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/62254
= help: add `#![feature(slice_patterns)]` to the crate attributes to enable
error[E0658]: syntax for subslices in slice patterns is not yet stabilized
error[E0658]: subslice patterns are unstable
--> $DIR/feature-gate-slice-patterns.rs:15:17
|
LL | [ 1, 2, xs.. ] => {}
| ^^
LL | [ 1, 2, xs @ .. ] => {}
| ^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/62254
= help: add `#![feature(slice_patterns)]` to the crate attributes to enable

View file

@ -1,8 +1,8 @@
error: unreachable pattern
--> $DIR/issue-12369.rs:10:9
|
LL | &[10,a, ref rest..] => 10
| ^^^^^^^^^^^^^^^^^^^
LL | &[10,a, ref rest @ ..] => 10
| ^^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/issue-12369.rs:2:9

View file

@ -19,8 +19,8 @@ LL | [0] => {},
error[E0528]: pattern requires at least 4 elements but array has 3
--> $DIR/match-vec-mismatch.rs:25:9
|
LL | [0, 1, 2, 3, x..] => {}
| ^^^^^^^^^^^^^^^^^ pattern cannot match array of 3 elements
LL | [0, 1, 2, 3, x @ ..] => {}
| ^^^^^^^^^^^^^^^^^^^^ pattern cannot match array of 3 elements
error[E0282]: type annotations needed
--> $DIR/match-vec-mismatch.rs:36:9

View file

@ -1,7 +1,12 @@
fn main() {
let a = Vec::new();
match a {
[1, tail @ .., tail @ ..] => {}, //~ ERROR: expected one of `,` or `@`, found `..`
[1, tail @ .., tail @ ..] => {},
//~^ ERROR identifier `tail` is bound more than once in the same pattern
//~| ERROR subslice patterns are unstable
//~| ERROR subslice patterns are unstable
//~| ERROR `..` can only be used once per slice pattern
//~| ERROR expected an array or slice, found `std::vec::Vec<_>`
_ => ()
}
}

View file

@ -1,8 +1,42 @@
error: expected one of `,` or `@`, found `..`
--> $DIR/match-vec-invalid.rs:4:25
error[E0416]: identifier `tail` is bound more than once in the same pattern
--> $DIR/match-vec-invalid.rs:4:24
|
LL | [1, tail.., tail..] => {},
| ^^ expected one of `,` or `@` here
LL | [1, tail @ .., tail @ ..] => {},
| ^^^^ used in a pattern more than once
error: aborting due to previous error
error[E0658]: subslice patterns are unstable
--> $DIR/match-vec-invalid.rs:4:13
|
LL | [1, tail @ .., tail @ ..] => {},
| ^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/62254
= help: add #![feature(slice_patterns)] to the crate attributes to enable
error[E0658]: subslice patterns are unstable
--> $DIR/match-vec-invalid.rs:4:24
|
LL | [1, tail @ .., tail @ ..] => {},
| ^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/62254
= help: add #![feature(slice_patterns)] to the crate attributes to enable
error: `..` can only be used once per slice pattern
--> $DIR/match-vec-invalid.rs:4:31
|
LL | [1, tail @ .., tail @ ..] => {},
| -- ^^ can only be used once per slice pattern
| |
| previously used here
error[E0529]: expected an array or slice, found `std::vec::Vec<_>`
--> $DIR/match-vec-invalid.rs:4:9
|
LL | [1, tail @ .., tail @ ..] => {},
| ^^^^^^^^^^^^^^^^^^^^^^^^^ pattern cannot match with input type `std::vec::Vec<_>`
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0416, E0529, E0658.
For more information about an error, try `rustc --explain E0416`.

View file

@ -1,6 +1,6 @@
fn main() {
match (0, 1, 2) {
(.., pat, ..) => {}
//~^ ERROR `..` can only be used once per tuple or tuple struct pattern
//~^ ERROR `..` can only be used once per tuple pattern
}
}

View file

@ -1,10 +1,10 @@
error: `..` can only be used once per tuple or tuple struct pattern
error: `..` can only be used once per tuple pattern
--> $DIR/pat-tuple-3.rs:3:19
|
LL | (.., pat, ..) => {}
| -- ^^ can only be used once per pattern
| -- ^^ can only be used once per tuple pattern
| |
| previously present here
| previously used here
error: aborting due to previous error