]> git.lizzy.rs Git - rust.git/blob - src/test/ui/or-patterns/inconsistent-modes.rs
Auto merge of #82864 - jyn514:short-circuit, r=GuillaumeGomez
[rust.git] / src / test / ui / or-patterns / inconsistent-modes.rs
1 // This test ensures that or patterns require binding mode consistency across arms.
2
3 #![allow(non_camel_case_types)]
4 fn main() {
5     // One level:
6     let (Ok(a) | Err(ref a)): Result<&u8, u8> = Ok(&0);
7     //~^ ERROR variable `a` is bound inconsistently
8     let (Ok(ref mut a) | Err(a)): Result<u8, &mut u8> = Ok(0);
9     //~^ ERROR variable `a` is bound inconsistently
10     let (Ok(ref a) | Err(ref mut a)): Result<&u8, &mut u8> = Ok(&0);
11     //~^ ERROR variable `a` is bound inconsistently
12     //~| ERROR mismatched types
13     let (Ok((ref a, b)) | Err((ref mut a, ref b))) = Ok((0, &0));
14     //~^ ERROR variable `a` is bound inconsistently
15     //~| ERROR variable `b` is bound inconsistently
16     //~| ERROR mismatched types
17
18     // Two levels:
19     let (Ok(Ok(a) | Err(a)) | Err(ref a)) = Err(0);
20     //~^ ERROR variable `a` is bound inconsistently
21
22     // Three levels:
23     let (Ok([Ok((Ok(ref a) | Err(a),)) | Err(a)]) | Err(a)) = Err(&1);
24     //~^ ERROR variable `a` is bound inconsistently
25 }