add new test and combine old ones

This commit is contained in:
ouz-a 2022-08-17 13:21:03 +03:00
parent 661d488bfd
commit ddf23cbeba
6 changed files with 65 additions and 47 deletions

View File

@ -1,13 +0,0 @@
#[allow(unused_variables)]
#[allow(unused_parens)]
fn main() {
let x = "foo";
match x {
x @ ((("h" | "ho" | "yo" | ("dude" | "w")) | () | "nop") | ("hey" | "gg")) |
//~^ ERROR mismatched types
x @ ("black" | "pink") |
x @ ("red" | "blue") => {
}
_ => (),
}
}

View File

@ -1,15 +0,0 @@
// run-pass
#[allow(unreachable_patterns)]
#[allow(unused_variables)]
#[allow(unused_parens)]
fn main() {
let x = "foo";
match x {
x @ ("foo" | "bar") |
(x @ "red" | (x @ "blue" | x @ "red")) => {
}
_ => (),
}
}

View File

@ -1,13 +0,0 @@
#[allow(unused_variables)]
#[allow(unused_parens)]
fn main() {
let x = "foo";
match x {
x @ ("foo" | "bar") |
(x @ "red" | (x @ "blue" | "red")) => {
//~^ variable `x` is not bound in all patterns
}
_ => (),
}
}

View File

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/inner-or-pat-2.rs:6:54
--> $DIR/inner-or-pat.rs:38:54
|
LL | match x {
| - this expression has type `&str`

View File

@ -1,5 +1,5 @@
error[E0408]: variable `x` is not bound in all patterns
--> $DIR/inner-or-pat-4.rs:8:37
--> $DIR/inner-or-pat.rs:53:37
|
LL | (x @ "red" | (x @ "blue" | "red")) => {
| - ^^^^^ pattern doesn't bind `x`

View File

@ -1,8 +1,16 @@
// run-pass
// revisions: or1 or2 or3 or4 or5
// [or1] run-pass
// [or2] run-pass
// [or5] run-pass
#[allow(unused_variables)]
#[allow(unused_parens)]
fn main() {
#![allow(unreachable_patterns)]
#![allow(unused_variables)]
#![allow(unused_parens)]
#![allow(dead_code)]
fn foo() {
let x = "foo";
match x {
x @ ((("h" | "ho" | "yo" | ("dude" | "w")) | "no" | "nop") | ("hey" | "gg")) |
@ -12,3 +20,54 @@ fn main() {
_ => (),
}
}
fn bar() {
let x = "foo";
match x {
x @ ("foo" | "bar") |
(x @ "red" | (x @ "blue" | x @ "red")) => {
}
_ => (),
}
}
#[cfg(or3)]
fn zot() {
let x = "foo";
match x {
x @ ((("h" | "ho" | "yo" | ("dude" | "w")) | () | "nop") | ("hey" | "gg")) |
//[or3]~^ ERROR mismatched types
x @ ("black" | "pink") |
x @ ("red" | "blue") => {
}
_ => (),
}
}
#[cfg(or4)]
fn hey() {
let x = "foo";
match x {
x @ ("foo" | "bar") |
(x @ "red" | (x @ "blue" | "red")) => {
//[or4]~^ variable `x` is not bound in all patterns
}
_ => (),
}
}
fn don() {
enum Foo {
A,
B,
C,
}
match Foo::A {
| _foo @ (Foo::A | Foo::B) => {}
Foo::C => {}
};
}
fn main(){}