1 // This test tests the precedence of `|` (or-patterns) undelimited nested patterns. In particular,
2 // we want to reserve the syntactic space of a pattern followed by a type annotation for possible
3 // future type ascription, so we need to make sure that any time a pattern is followed by type
4 // annotation (for now), the pattern is not a top-level or-pattern. However, there are also a few
5 // types of patterns that allow undelimited subpatterns that could cause the same ambiguity.
6 // Currently, those should be impossible due to precedence rule. This test enforces that.
8 #![feature(or_patterns)]
19 let b @ (A | B): E = A;
21 let b @ A | B: E = A; //~ERROR `b` is not bound in all patterns
22 //~^ ERROR top-level or-patterns are not allowed
34 let (A(x) | B(x)): F = A(3);
36 let &A(_) | B(_): F = A(3); //~ERROR mismatched types
37 //~^ ERROR top-level or-patterns are not allowed
38 let &&A(_) | B(_): F = A(3); //~ERROR mismatched types
39 //~^ ERROR top-level or-patterns are not allowed
40 let &mut A(_) | B(_): F = A(3); //~ERROR mismatched types
41 //~^ ERROR top-level or-patterns are not allowed
42 let &&mut A(_) | B(_): F = A(3); //~ERROR mismatched types
43 //~^ ERROR top-level or-patterns are not allowed