rust/src/test/ui/or-patterns/or-patterns-syntactic-fail.rs

22 lines
740 B
Rust
Raw Normal View History

2019-08-18 16:53:08 -05:00
// Test some cases where or-patterns may ostensibly be allowed but are in fact not.
// This is not a semantic test. We only test parsing.
#![feature(or_patterns)]
fn main() {}
enum E { A, B }
use E::*;
fn no_top_level_or_patterns() {
// We do *not* allow or-patterns at the top level of lambdas...
2019-12-11 16:11:32 -06:00
let _ = |A | B: E| (); //~ ERROR no implementation for `E | ()`
2019-08-18 16:53:08 -05:00
// -------- This looks like an or-pattern but is in fact `|A| (B: E | ())`.
// ...and for now neither do we allow or-patterns at the top level of functions.
fn fun1(A | B: E) {} //~ ERROR an or-pattern parameter must be wrapped in parentheses
fn fun2(| A | B: E) {}
//~^ ERROR an or-pattern parameter must be wrapped in parentheses
2019-08-18 16:53:08 -05:00
}