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