1 // Test some cases where or-patterns may ostensibly be allowed but are in fact not.
2 // This is not a semantic test. We only test parsing.
9 fn no_top_level_or_patterns() {
10 // We do *not* allow or-patterns at the top level of lambdas...
11 let _ = |A | B: E| (); //~ ERROR no implementation for `E | ()`
12 // -------- This looks like an or-pattern but is in fact `|A| (B: E | ())`.
14 // ...and for now neither do we allow or-patterns at the top level of functions.
16 //~^ ERROR top-level or-patterns are not allowed
18 fn fun2(| A | B: E) {}
19 //~^ ERROR top-level or-patterns are not allowed
21 // We don't allow top-level or-patterns before type annotation in let-statements because we
22 // want to reserve this syntactic space for possible future type ascription.
24 //~^ ERROR top-level or-patterns are not allowed
27 //~^ ERROR top-level or-patterns are not allowed
29 let (A | B): E = A; // ok -- wrapped in parens