summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs
blob: 2ad92b79444925ac56ba7d8affbb050b64d17a72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 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
        NonExhaustiveMonovariant::Variant(_) => {},
        _ => {},
    }
    drop(y);
}