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