mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 12:13:43 +00:00
add new test and combine old ones
This commit is contained in:
parent
661d488bfd
commit
ddf23cbeba
@ -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") => {
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
@ -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")) => {
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
@ -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`
|
@ -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`
|
@ -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(){}
|
||||
|
Loading…
Reference in New Issue
Block a user