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.
|
2021-02-07 20:40:33 -06:00
|
|
|
fn fun1(A | B: E) {} //~ ERROR an or-pattern parameter must be wrapped in parentheses
|
2019-08-24 21:39:28 -05:00
|
|
|
|
|
|
|
fn fun2(| A | B: E) {}
|
2021-02-07 20:40:33 -06:00
|
|
|
//~^ ERROR an or-pattern parameter must be wrapped in parentheses
|
2019-08-18 16:53:08 -05:00
|
|
|
}
|