2019-09-01 21:24:07 +00:00
|
|
|
// This test ensures that or patterns require binding mode consistency across arms.
|
|
|
|
|
|
|
|
#![feature(or_patterns)]
|
2019-09-03 02:32:50 +00:00
|
|
|
#![allow(non_camel_case_types)]
|
2019-09-01 21:24:07 +00:00
|
|
|
fn main() {
|
|
|
|
// One level:
|
|
|
|
let Ok(a) | Err(ref a): Result<&u8, u8> = Ok(&0);
|
2020-03-04 02:58:52 +00:00
|
|
|
//~^ ERROR variable `a` is bound inconsistently
|
2019-09-01 21:24:07 +00:00
|
|
|
let Ok(ref mut a) | Err(a): Result<u8, &mut u8> = Ok(0);
|
2020-03-04 02:58:52 +00:00
|
|
|
//~^ ERROR variable `a` is bound inconsistently
|
2019-09-01 21:24:07 +00:00
|
|
|
let Ok(ref a) | Err(ref mut a): Result<&u8, &mut u8> = Ok(&0);
|
2020-03-04 02:58:52 +00:00
|
|
|
//~^ ERROR variable `a` is bound inconsistently
|
2019-09-01 21:24:07 +00:00
|
|
|
//~| ERROR mismatched types
|
|
|
|
let Ok((ref a, b)) | Err((ref mut a, ref b)) = Ok((0, &0));
|
2020-03-04 02:58:52 +00:00
|
|
|
//~^ ERROR variable `a` is bound inconsistently
|
|
|
|
//~| ERROR variable `b` is bound inconsistently
|
2019-09-01 21:24:07 +00:00
|
|
|
//~| ERROR mismatched types
|
|
|
|
|
|
|
|
// Two levels:
|
|
|
|
let Ok(Ok(a) | Err(a)) | Err(ref a) = Err(0);
|
2020-03-04 02:58:52 +00:00
|
|
|
//~^ ERROR variable `a` is bound inconsistently
|
2019-09-01 21:24:07 +00:00
|
|
|
|
|
|
|
// Three levels:
|
2020-03-04 02:58:52 +00:00
|
|
|
let Ok([Ok((Ok(ref a) | Err(a),)) | Err(a)]) | Err(a) = Err(&1);
|
|
|
|
//~^ ERROR variable `a` is bound inconsistently
|
2019-09-01 21:24:07 +00:00
|
|
|
}
|