2023-04-29 19:00:00 -05:00
|
|
|
// Test precise capture of a multi-variant enum (when remaining variants are
|
|
|
|
// visibly uninhabited).
|
2024-07-27 04:08:16 -05:00
|
|
|
//@ revisions: normal exhaustive_patterns
|
2023-04-29 19:00:00 -05:00
|
|
|
//@ edition:2021
|
|
|
|
//@ run-pass
|
2024-02-08 04:27:46 -06:00
|
|
|
#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
|
2023-04-29 19:00:00 -05:00
|
|
|
#![feature(never_type)]
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
let mut r = Result::<!, (u32, u32)>::Err((0, 0));
|
|
|
|
let mut f = || {
|
|
|
|
let Err((ref mut a, _)) = r;
|
|
|
|
*a = 1;
|
|
|
|
};
|
|
|
|
let mut g = || {
|
|
|
|
let Err((_, ref mut b)) = r;
|
|
|
|
*b = 2;
|
|
|
|
};
|
|
|
|
f();
|
|
|
|
g();
|
|
|
|
assert_eq!(r, Err((1, 2)));
|
|
|
|
}
|