]> git.lizzy.rs Git - rust.git/blob - tests/ui/closures/2229_closure_analysis/match/match-edge-cases_2.rs
Merge commit '7f27e2e74ef957baa382dc05cf08df6368165c74' into clippyup
[rust.git] / tests / ui / closures / 2229_closure_analysis / match / match-edge-cases_2.rs
1 // edition:2021
2
3 enum SingleVariant {
4     A
5 }
6
7 struct TestStruct {
8     x: i32,
9     y: i32,
10     z: i32,
11 }
12
13 fn edge_case_if() {
14     let sv = SingleVariant::A;
15     let condition = true;
16     // sv should not be captured as it is a SingleVariant
17     let _a = || {
18         match sv {
19             SingleVariant::A if condition => (),
20             _ => ()
21         }
22     };
23     let mut mut_sv = sv;
24     _a();
25
26     // ts should be captured
27     let ts = TestStruct { x: 1, y: 1, z: 1 };
28     let _b = || { match ts {
29         TestStruct{ x: 1, .. } => (),
30         _ => ()
31     }};
32     let mut mut_ts = ts;
33     //~^ ERROR: cannot move out of `ts` because it is borrowed
34     _b();
35 }
36
37 fn main() {}