Skip to content

Commit 33817d2

Browse files
committed
Move match tests in match folder
1 parent f7b0e3b commit 33817d2

File tree

6 files changed

+38
-35
lines changed

6 files changed

+38
-35
lines changed

src/test/ui/closures/2229_closure_analysis/match/match-edge-cases.rs renamed to src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_1.rs

-34
Original file line numberDiff line numberDiff line change
@@ -41,38 +41,4 @@ pub fn edge_case_char(event: char) {
4141
};
4242
}
4343

44-
enum SingleVariant {
45-
A
46-
}
47-
48-
struct TestStruct {
49-
x: i32,
50-
y: i32,
51-
z: i32,
52-
}
53-
54-
fn edge_case_if() {
55-
let sv = SingleVariant::A;
56-
let condition = true;
57-
// sv should not be captured as it is a SingleVariant
58-
let _a = || {
59-
match sv {
60-
SingleVariant::A if condition => (),
61-
_ => ()
62-
}
63-
};
64-
let mut mut_sv = sv;
65-
_a();
66-
67-
// ts should be captured
68-
let ts = TestStruct { x: 1, y: 1, z: 1 };
69-
let _b = || { match ts {
70-
TestStruct{ x: 1, .. } => (),
71-
_ => ()
72-
}};
73-
let mut mut_ts = ts;
74-
//~^ ERROR: cannot move out of `ts` because it is borrowed
75-
_b();
76-
}
77-
7844
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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() {}

src/test/ui/closures/2229_closure_analysis/match/match-edge-cases.stderr renamed to src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0505]: cannot move out of `ts` because it is borrowed
2-
--> $DIR/match-edge-cases.rs:32:22
2+
--> $DIR/match-edge-cases_2.rs:32:22
33
|
44
LL | let _b = || { match ts {
55
| -- -- borrow occurs due to use in closure

0 commit comments

Comments
 (0)