]>
git.proxmox.com Git - rustc.git/blob - tests/ui/or-patterns/missing-bindings.rs
1 // This test ensures that or patterns do not allow missing bindings in any of the arms.
5 #![allow(non_camel_case_types)]
9 fn check_handling_of_paths() {
18 use bar
::foo
::{alpha, charlie}
;
19 let (alpha
| beta
| charlie
) = alpha
; //~ ERROR variable `beta` is not bound in all patterns
21 Some(alpha
| beta
) => {}
//~ ERROR variable `beta` is not bound in all patterns
25 fn check_misc_nesting() {
26 enum E
<T
> { A(T, T), B(T) }
28 enum Vars3
<S
, T
, U
> { V1(S), V2(T), V3(U) }
32 const X
: E
<u8> = B(0);
33 let (A(a
, _
) | _
) = X
; //~ ERROR variable `a` is not bound in all patterns
34 let (_
| B(a
)) = X
; //~ ERROR variable `a` is not bound in all patterns
35 let (A(..) | B(a
)) = X
; //~ ERROR variable `a` is not bound in all patterns
36 let (A(a
, _
) | B(_
)) = X
; //~ ERROR variable `a` is not bound in all patterns
37 let (A(_
, a
) | B(_
)) = X
; //~ ERROR variable `a` is not bound in all patterns
38 let (A(a
, b
) | B(a
)) = X
; //~ ERROR variable `b` is not bound in all patterns
41 const Y
: E
<E
<u8>> = B(B(0));
42 let (A(A(..) | B(_
), _
) | B(a
)) = Y
; //~ ERROR variable `a` is not bound in all patterns
43 let (A(A(..) | B(a
), _
) | B(A(a
, _
) | B(a
))) = Y
;
44 //~^ ERROR variable `a` is not bound in all patterns
45 let (A(A(a
, b
) | B(c
), d
) | B(e
)) = Y
;
46 //~^ ERROR variable `a` is not bound in all patterns
47 //~| ERROR variable `a` is not bound in all patterns
48 //~| ERROR variable `b` is not bound in all patterns
49 //~| ERROR variable `b` is not bound in all patterns
50 //~| ERROR variable `c` is not bound in all patterns
51 //~| ERROR variable `c` is not bound in all patterns
52 //~| ERROR variable `d` is not bound in all patterns
53 //~| ERROR variable `e` is not bound in all patterns
58 //~^ ERROR variable `b` is not bound in all patterns
59 //~| ERROR variable `c` is not bound in all patterns
61 Ok(a
) | Err(_
), //~ ERROR variable `a` is not bound in all patterns
68 A(_
, a
) | //~ ERROR variable `b` is not bound in all patterns
69 B(b
), //~ ERROR variable `a` is not bound in all patterns
73 //~^ ERROR variable `a` is not bound in all patterns
74 //~| ERROR variable `b` is not bound in all patterns
77 //~^ ERROR variable `a` is not bound in all patterns
79 : (Vars3
<E
<Result
<u8, u8>>, E
<E
<u8>>, u8>,)