Add & bless tests
This commit is contained in:
parent
91bc117e53
commit
a3bb9fb8c5
9 changed files with 221 additions and 36 deletions
|
@ -11,12 +11,8 @@ fn foo() {
|
||||||
//~| ERROR range-to patterns with `...` are not allowed
|
//~| ERROR range-to patterns with `...` are not allowed
|
||||||
if let ..5 = 0 {}
|
if let ..5 = 0 {}
|
||||||
//~^ ERROR half-open range patterns are unstable
|
//~^ ERROR half-open range patterns are unstable
|
||||||
if let 5.. = 0 {}
|
|
||||||
//~^ ERROR half-open range patterns are unstable
|
|
||||||
if let 5..= = 0 {}
|
if let 5..= = 0 {}
|
||||||
//~^ ERROR half-open range patterns are unstable
|
//~^ ERROR inclusive range with no end
|
||||||
//~| ERROR inclusive range with no end
|
|
||||||
if let 5... = 0 {}
|
if let 5... = 0 {}
|
||||||
//~^ ERROR half-open range patterns are unstable
|
//~^ ERROR inclusive range with no end
|
||||||
//~| ERROR inclusive range with no end
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ LL | if let ...5 = 0 {}
|
||||||
| ^^^ help: use `..=` instead
|
| ^^^ help: use `..=` instead
|
||||||
|
|
||||||
error[E0586]: inclusive range with no end
|
error[E0586]: inclusive range with no end
|
||||||
--> $DIR/feature-gate-half-open-range-patterns.rs:16:13
|
--> $DIR/feature-gate-half-open-range-patterns.rs:14:13
|
||||||
|
|
|
|
||||||
LL | if let 5..= = 0 {}
|
LL | if let 5..= = 0 {}
|
||||||
| ^^^ help: use `..` instead
|
| ^^^ help: use `..` instead
|
||||||
|
@ -13,7 +13,7 @@ LL | if let 5..= = 0 {}
|
||||||
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
|
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
|
||||||
|
|
||||||
error[E0586]: inclusive range with no end
|
error[E0586]: inclusive range with no end
|
||||||
--> $DIR/feature-gate-half-open-range-patterns.rs:19:13
|
--> $DIR/feature-gate-half-open-range-patterns.rs:16:13
|
||||||
|
|
|
|
||||||
LL | if let 5... = 0 {}
|
LL | if let 5... = 0 {}
|
||||||
| ^^^ help: use `..` instead
|
| ^^^ help: use `..` instead
|
||||||
|
@ -47,34 +47,7 @@ LL | if let ..5 = 0 {}
|
||||||
= note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
|
= note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
|
||||||
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
|
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: half-open range patterns are unstable
|
error: aborting due to 6 previous errors
|
||||||
--> $DIR/feature-gate-half-open-range-patterns.rs:14:12
|
|
||||||
|
|
|
||||||
LL | if let 5.. = 0 {}
|
|
||||||
| ^^^
|
|
||||||
|
|
|
||||||
= note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
|
|
||||||
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
|
|
||||||
|
|
||||||
error[E0658]: half-open range patterns are unstable
|
|
||||||
--> $DIR/feature-gate-half-open-range-patterns.rs:16:12
|
|
||||||
|
|
|
||||||
LL | if let 5..= = 0 {}
|
|
||||||
| ^^^^
|
|
||||||
|
|
|
||||||
= note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
|
|
||||||
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
|
|
||||||
|
|
||||||
error[E0658]: half-open range patterns are unstable
|
|
||||||
--> $DIR/feature-gate-half-open-range-patterns.rs:19:12
|
|
||||||
|
|
|
||||||
LL | if let 5... = 0 {}
|
|
||||||
| ^^^^
|
|
||||||
|
|
|
||||||
= note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
|
|
||||||
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
|
|
||||||
|
|
||||||
error: aborting due to 9 previous errors
|
|
||||||
|
|
||||||
Some errors have detailed explanations: E0586, E0658.
|
Some errors have detailed explanations: E0586, E0658.
|
||||||
For more information about an error, try `rustc --explain E0586`.
|
For more information about an error, try `rustc --explain E0586`.
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
// run-pass
|
||||||
|
#![allow(incomplete_features)]
|
||||||
|
#![feature(exclusive_range_pattern)]
|
||||||
|
#![feature(half_open_range_patterns)]
|
||||||
|
#![feature(inline_const)]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut if_lettable = vec![];
|
||||||
|
let mut first_or = vec![];
|
||||||
|
let mut or_two = vec![];
|
||||||
|
let mut range_from = vec![];
|
||||||
|
let mut bottom = vec![];
|
||||||
|
|
||||||
|
for x in -9 + 1..=(9 - 2) {
|
||||||
|
if let -1..=0 | 2..3 | 4 = x {
|
||||||
|
if_lettable.push(x)
|
||||||
|
}
|
||||||
|
match x {
|
||||||
|
1 | -3..0 => first_or.push(x),
|
||||||
|
y @ (0..5 | 6) => or_two.push(y),
|
||||||
|
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
|
||||||
|
y @ -5.. => range_from.push(y),
|
||||||
|
y @ ..-7 => assert_eq!(y, -8),
|
||||||
|
y => bottom.push(y),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert_eq!(if_lettable, [-1, 0, 2, 4]);
|
||||||
|
assert_eq!(first_or, [-3, -2, -1, 1]);
|
||||||
|
assert_eq!(or_two, [0, 2, 3, 4, 6]);
|
||||||
|
assert_eq!(range_from, [-5, -4, 7]);
|
||||||
|
assert_eq!(bottom, [-7, -6]);
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
fn main() {
|
||||||
|
let mut if_lettable = Vec::<i32>::new();
|
||||||
|
let mut first_or = Vec::<i32>::new();
|
||||||
|
let mut or_two = Vec::<i32>::new();
|
||||||
|
let mut range_from = Vec::<i32>::new();
|
||||||
|
let mut bottom = Vec::<i32>::new();
|
||||||
|
let mut errors_only = Vec::<i32>::new();
|
||||||
|
|
||||||
|
for x in -9 + 1..=(9 - 2) {
|
||||||
|
if let n @ 2..3|4 = x {
|
||||||
|
//~^ error: variable `n` is not bound in all patterns
|
||||||
|
//~| exclusive range pattern syntax is experimental
|
||||||
|
errors_only.push(x);
|
||||||
|
} else if let 2..3 | 4 = x {
|
||||||
|
//~^ exclusive range pattern syntax is experimental
|
||||||
|
if_lettable.push(x);
|
||||||
|
}
|
||||||
|
match x as i32 {
|
||||||
|
0..5+1 => errors_only.push(x),
|
||||||
|
//~^ error: expected one of `=>`, `if`, or `|`, found `+`
|
||||||
|
1 | -3..0 => first_or.push(x),
|
||||||
|
y @ (0..5 | 6) => or_two.push(y),
|
||||||
|
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
|
||||||
|
y @ -5.. => range_from.push(y),
|
||||||
|
y @ ..-7 => assert_eq!(y, -8),
|
||||||
|
y => bottom.push(y),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
error: expected one of `=>`, `if`, or `|`, found `+`
|
||||||
|
--> $DIR/range_pat_interactions1.rs:19:17
|
||||||
|
|
|
||||||
|
LL | 0..5+1 => errors_only.push(x),
|
||||||
|
| ^ expected one of `=>`, `if`, or `|`
|
||||||
|
|
||||||
|
error[E0408]: variable `n` is not bound in all patterns
|
||||||
|
--> $DIR/range_pat_interactions1.rs:10:25
|
||||||
|
|
|
||||||
|
LL | if let n @ 2..3|4 = x {
|
||||||
|
| - ^ pattern doesn't bind `n`
|
||||||
|
| |
|
||||||
|
| variable not in all patterns
|
||||||
|
|
||||||
|
error[E0658]: exclusive range pattern syntax is experimental
|
||||||
|
--> $DIR/range_pat_interactions1.rs:10:20
|
||||||
|
|
|
||||||
|
LL | if let n @ 2..3|4 = x {
|
||||||
|
| ^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
|
||||||
|
= help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: exclusive range pattern syntax is experimental
|
||||||
|
--> $DIR/range_pat_interactions1.rs:14:23
|
||||||
|
|
|
||||||
|
LL | } else if let 2..3 | 4 = x {
|
||||||
|
| ^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
|
||||||
|
= help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0408, E0658.
|
||||||
|
For more information about an error, try `rustc --explain E0408`.
|
|
@ -0,0 +1,21 @@
|
||||||
|
fn main() {
|
||||||
|
let mut first_or = Vec::<i32>::new();
|
||||||
|
let mut or_two = Vec::<i32>::new();
|
||||||
|
let mut range_from = Vec::<i32>::new();
|
||||||
|
let mut bottom = Vec::<i32>::new();
|
||||||
|
let mut errors_only = Vec::<i32>::new();
|
||||||
|
|
||||||
|
for x in -9 + 1..=(9 - 2) {
|
||||||
|
match x as i32 {
|
||||||
|
0..=(5+1) => errors_only.push(x),
|
||||||
|
//~^ error: inclusive range with no end
|
||||||
|
//~| error: expected one of `=>`, `if`, or `|`, found `(`
|
||||||
|
1 | -3..0 => first_or.push(x),
|
||||||
|
y @ (0..5 | 6) => or_two.push(y),
|
||||||
|
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
|
||||||
|
y @ -5.. => range_from.push(y),
|
||||||
|
y @ ..-7 => assert_eq!(y, -8),
|
||||||
|
y => bottom.push(y),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
error[E0586]: inclusive range with no end
|
||||||
|
--> $DIR/range_pat_interactions2.rs:10:14
|
||||||
|
|
|
||||||
|
LL | 0..=(5+1) => errors_only.push(x),
|
||||||
|
| ^^^ help: use `..` instead
|
||||||
|
|
|
||||||
|
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
|
||||||
|
|
||||||
|
error: expected one of `=>`, `if`, or `|`, found `(`
|
||||||
|
--> $DIR/range_pat_interactions2.rs:10:17
|
||||||
|
|
|
||||||
|
LL | 0..=(5+1) => errors_only.push(x),
|
||||||
|
| ^ expected one of `=>`, `if`, or `|`
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0586`.
|
|
@ -0,0 +1,24 @@
|
||||||
|
fn main() {
|
||||||
|
let mut first_or = Vec::<i32>::new();
|
||||||
|
let mut or_two = Vec::<i32>::new();
|
||||||
|
let mut range_from = Vec::<i32>::new();
|
||||||
|
let mut bottom = Vec::<i32>::new();
|
||||||
|
|
||||||
|
for x in -9 + 1..=(9 - 2) {
|
||||||
|
match x as i32 {
|
||||||
|
8.. => bottom.push(x),
|
||||||
|
1 | -3..0 => first_or.push(x),
|
||||||
|
//~^ exclusive range pattern syntax is experimental
|
||||||
|
y @ (0..5 | 6) => or_two.push(y),
|
||||||
|
//~^ exclusive range pattern syntax is experimental
|
||||||
|
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
|
||||||
|
//~^ inline-const is experimental
|
||||||
|
//~| exclusive range pattern syntax is experimental
|
||||||
|
y @ -5.. => range_from.push(y),
|
||||||
|
y @ ..-7 => assert_eq!(y, -8),
|
||||||
|
//~^ half-open range patterns are unstable
|
||||||
|
//~| exclusive range pattern syntax is experimental
|
||||||
|
y => bottom.push(y),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
error[E0658]: half-open range patterns are unstable
|
||||||
|
--> $DIR/range_pat_interactions3.rs:18:17
|
||||||
|
|
|
||||||
|
LL | y @ ..-7 => assert_eq!(y, -8),
|
||||||
|
| ^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
|
||||||
|
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: inline-const is experimental
|
||||||
|
--> $DIR/range_pat_interactions3.rs:14:20
|
||||||
|
|
|
||||||
|
LL | y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
|
||||||
|
= help: add `#![feature(inline_const)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: exclusive range pattern syntax is experimental
|
||||||
|
--> $DIR/range_pat_interactions3.rs:10:17
|
||||||
|
|
|
||||||
|
LL | 1 | -3..0 => first_or.push(x),
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
|
||||||
|
= help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: exclusive range pattern syntax is experimental
|
||||||
|
--> $DIR/range_pat_interactions3.rs:12:18
|
||||||
|
|
|
||||||
|
LL | y @ (0..5 | 6) => or_two.push(y),
|
||||||
|
| ^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
|
||||||
|
= help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: exclusive range pattern syntax is experimental
|
||||||
|
--> $DIR/range_pat_interactions3.rs:14:17
|
||||||
|
|
|
||||||
|
LL | y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
|
||||||
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
|
||||||
|
= help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: exclusive range pattern syntax is experimental
|
||||||
|
--> $DIR/range_pat_interactions3.rs:18:17
|
||||||
|
|
|
||||||
|
LL | y @ ..-7 => assert_eq!(y, -8),
|
||||||
|
| ^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information
|
||||||
|
= help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0658`.
|
Loading…
Add table
Add a link
Reference in a new issue