2019-11-24 16:39:05 -06:00
|
|
|
// Test that the borrow checker considers `#[non_exhaustive]` when checking
|
|
|
|
// whether a match contains a discriminant read.
|
|
|
|
|
|
|
|
// aux-build:monovariants.rs
|
|
|
|
extern crate monovariants;
|
|
|
|
|
|
|
|
use monovariants::NonExhaustiveMonovariant;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut x = NonExhaustiveMonovariant::Variant(1);
|
|
|
|
let y = &mut x;
|
|
|
|
match x {
|
|
|
|
//~^ ERROR cannot use `x` because it was mutably borrowed
|
2021-07-23 17:55:36 -05:00
|
|
|
NonExhaustiveMonovariant::Variant(_) => {},
|
2019-11-24 16:39:05 -06:00
|
|
|
_ => {},
|
|
|
|
}
|
|
|
|
drop(y);
|
|
|
|
}
|