rust/tests/ui/rfcs/rfc-0000-never_patterns/parse.rs
2023-12-03 12:25:46 +01:00

72 lines
1.4 KiB
Rust

#![feature(never_patterns)]
#![allow(incomplete_features)]
enum Void {}
fn main() {}
macro_rules! never {
() => { ! }
}
fn parse(x: Void) {
match None::<Void> {
None => {}
Some(!),
}
match None::<Void> {
Some(!),
None => {}
}
match None::<Void> {
None => {}
Some(!)
}
match None::<Void> {
Some(!)
//~^ ERROR expected `,` following `match` arm
None => {}
}
match None::<Void> {
Some(!) if true
//~^ ERROR expected `,` following `match` arm
//~| ERROR guard on a never pattern
None => {}
}
match None::<Void> {
Some(!) if true,
//~^ ERROR guard on a never pattern
None => {}
}
match None::<Void> {
Some(!) <=
//~^ ERROR expected one of
}
match x {
never!(),
}
match x {
never!() if true,
//~^ ERROR guard on a never pattern
}
match x {
never!()
}
match &x {
&never!(),
}
match None::<Void> {
Some(never!()),
None => {}
}
match x { ! }
match &x { &! }
let res: Result<bool, Void> = Ok(false);
let Ok(_) = res;
let Ok(_) | Err(!) = &res; // Disallowed; see #82048.
//~^ ERROR top-level or-patterns are not allowed in `let` bindings
let (Ok(_) | Err(!)) = &res;
let (Ok(_) | Err(&!)) = res.as_ref();
}