Skip to content

Commit

Permalink
add new test and combine old ones
Browse files Browse the repository at this point in the history
  • Loading branch information
ouz-a committed Aug 17, 2022
1 parent 661d488 commit ddf23cb
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 47 deletions.
13 changes: 0 additions & 13 deletions src/test/ui/or-patterns/inner-or-pat-2.rs

This file was deleted.

15 changes: 0 additions & 15 deletions src/test/ui/or-patterns/inner-or-pat-3.rs

This file was deleted.

13 changes: 0 additions & 13 deletions src/test/ui/or-patterns/inner-or-pat-4.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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`
Expand Down
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
67 changes: 63 additions & 4 deletions src/test/ui/or-patterns/inner-or-pat.rs
Original file line number Diff line number Diff line change
@@ -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")) |
Expand All @@ -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(){}

0 comments on commit ddf23cb

Please sign in to comment.