]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs
Auto merge of #94899 - workingjubilee:bump-simd-clamp, r=workingjubilee
[rust.git] / src / test / ui / rfc-2008-non-exhaustive / borrowck-non-exhaustive.rs
1 // Test that the borrow checker considers `#[non_exhaustive]` when checking
2 // whether a match contains a discriminant read.
3
4 // aux-build:monovariants.rs
5 extern crate monovariants;
6
7 use monovariants::NonExhaustiveMonovariant;
8
9 fn main() {
10     let mut x = NonExhaustiveMonovariant::Variant(1);
11     let y = &mut x;
12     match x {
13         //~^ ERROR cannot use `x` because it was mutably borrowed
14         NonExhaustiveMonovariant::Variant(_) => {},
15         _ => {},
16     }
17     drop(y);
18 }