-
Notifications
You must be signed in to change notification settings - Fork 32
/
borrowck-exhaustive.rs
51 lines (43 loc) · 1.01 KB
/
borrowck-exhaustive.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Test that the borrow checker doesn't consider checking an exhaustive pattern
// as an access.
//@ check-pass
#![allow(dropping_references)]
//@ aux-build:monovariants.rs
extern crate monovariants;
use monovariants::ExhaustiveMonovariant;
enum Local {
Variant(u32),
}
#[non_exhaustive]
enum LocalNonExhaustive {
Variant(u32),
}
fn main() {
let mut x = ExhaustiveMonovariant::Variant(1);
let y = &mut x;
match x {
ExhaustiveMonovariant::Variant(_) => {},
_ => {},
}
drop(y);
let mut x = Local::Variant(1);
let y = &mut x;
match x {
Local::Variant(_) => {},
_ => {},
}
drop(y);
let mut x = LocalNonExhaustive::Variant(1);
let y = &mut x;
match x {
LocalNonExhaustive::Variant(_) => {},
_ => {},
}
drop(y);
}
// ferrocene-annotations: fls_e5td0fa92fay
// Match Expressions
// ferrocene-annotations: fls_vlrto778v49m
// Tuple Struct Patterns
// ferrocene-annotations: fls_eexupzdsu7f
// Tuple Struct Pattern Matching