]> git.lizzy.rs Git - rust.git/blob - src/test/ui/or-patterns/inconsistent-modes.rs
Rollup merge of #70038 - DutchGhost:const-forget-tests, r=RalfJung
[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 #![feature(or_patterns)]
4 #![allow(non_camel_case_types)]
5 fn main() {
6     // One level:
7     let Ok(a) | Err(ref a): Result<&u8, u8> = Ok(&0);
8     //~^ ERROR variable `a` is bound inconsistently
9     let Ok(ref mut a) | Err(a): Result<u8, &mut u8> = Ok(0);
10     //~^ ERROR variable `a` is bound inconsistently
11     let Ok(ref a) | Err(ref mut a): Result<&u8, &mut u8> = Ok(&0);
12     //~^ ERROR variable `a` is bound inconsistently
13     //~| ERROR mismatched types
14     let Ok((ref a, b)) | Err((ref mut a, ref b)) = Ok((0, &0));
15     //~^ ERROR variable `a` is bound inconsistently
16     //~| ERROR variable `b` is bound inconsistently
17     //~| ERROR mismatched types
18
19     // Two levels:
20     let Ok(Ok(a) | Err(a)) | Err(ref a) = Err(0);
21     //~^ ERROR variable `a` is bound inconsistently
22
23     // Three levels:
24     let Ok([Ok((Ok(ref a) | Err(a),)) | Err(a)]) | Err(a) = Err(&1);
25     //~^ ERROR variable `a` is bound inconsistently
26 }