rust/tests/ui/rfcs/rfc-0000-never_patterns/bindings.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.3 KiB
Rust
Raw Normal View History

2024-01-05 03:08:47 -06:00
#![feature(never_patterns)]
#![allow(incomplete_features)]
#[derive(Copy, Clone)]
2024-01-05 03:08:47 -06:00
enum Void {}
fn main() {
let x: Result<bool, &(u32, u32, Void)> = Ok(false);
match x {
Ok(_x) | Err(&!) => {}
}
let (Ok(_x) | Err(&!)) = x;
match x {
Ok(_) => {}
Err(&(_a, _b, !)),
2024-01-05 03:11:18 -06:00
//~^ ERROR: never patterns cannot contain variable bindings
//~| ERROR: never patterns cannot contain variable bindings
2024-01-05 03:08:47 -06:00
}
match x {
Ok(_ok) | Err(&(_a, _b, !)) => {}
2024-01-05 03:11:18 -06:00
//~^ ERROR: never patterns cannot contain variable bindings
//~| ERROR: never patterns cannot contain variable bindings
2024-01-05 03:08:47 -06:00
}
}
2024-01-10 15:08:53 -06:00
fn void(void: Void) {
let (_a | !) = void;
let (! | _a) = void;
let ((_a, _) | (_a, _ | !)) = (true, void);
let (_a | (! | !,)) = (void,);
let ((_a,) | (!,)) = (void,);
let (_a, (! | !)) = (true, void);
//~^ ERROR: never patterns cannot contain variable bindings
let (_a, (_b | !)) = (true, void);
let _a @ ! = void;
//~^ ERROR: never patterns cannot contain variable bindings
let _a @ (_b | !) = void;
let (_a @ (), !) = ((), void);
//~^ ERROR: never patterns cannot contain variable bindings
let (_a |
(_b @ (_, !))) = (true, void);
//~^ ERROR: never patterns cannot contain variable bindings
}