mark `min_exhaustive_patterns` as complete This is step 1 and 2 of my [proposal](https://github.com/rust-lang/rust/issues/119612#issuecomment-1918097361) to move `min_exhaustive_patterns` forward. The vast majority of in-tree use cases of `exhaustive_patterns` are covered by `min_exhaustive_patterns`. There are a few cases that still require `exhaustive_patterns` in tests and they're all behind references. r? ``@ghost``
24 lines
636 B
Rust
24 lines
636 B
Rust
// Test precise capture of a multi-variant enum (when remaining variants are
|
|
// visibly uninhabited).
|
|
//@ revisions: min_exhaustive_patterns exhaustive_patterns
|
|
//@ edition:2021
|
|
//@ run-pass
|
|
#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
|
|
#![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))]
|
|
#![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)));
|
|
}
|