From 33817d2881843bb84a01551813c522891ce0c5c6 Mon Sep 17 00:00:00 2001 From: Roxane Date: Sat, 28 Aug 2021 19:54:12 -0400 Subject: [PATCH] Move match tests in match folder --- .../{ => match}/issue-87988.rs | 0 .../{ => match}/issue-88331.rs | 0 .../{ => match}/issue-88331.stderr | 0 ...ch-edge-cases.rs => match-edge-cases_1.rs} | 34 ----------------- .../match/match-edge-cases_2.rs | 37 +++++++++++++++++++ ...cases.stderr => match-edge-cases_2.stderr} | 2 +- 6 files changed, 38 insertions(+), 35 deletions(-) rename src/test/ui/closures/2229_closure_analysis/{ => match}/issue-87988.rs (100%) rename src/test/ui/closures/2229_closure_analysis/{ => match}/issue-88331.rs (100%) rename src/test/ui/closures/2229_closure_analysis/{ => match}/issue-88331.stderr (100%) rename src/test/ui/closures/2229_closure_analysis/match/{match-edge-cases.rs => match-edge-cases_1.rs} (53%) create mode 100644 src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_2.rs rename src/test/ui/closures/2229_closure_analysis/match/{match-edge-cases.stderr => match-edge-cases_2.stderr} (92%) diff --git a/src/test/ui/closures/2229_closure_analysis/issue-87988.rs b/src/test/ui/closures/2229_closure_analysis/match/issue-87988.rs similarity index 100% rename from src/test/ui/closures/2229_closure_analysis/issue-87988.rs rename to src/test/ui/closures/2229_closure_analysis/match/issue-87988.rs diff --git a/src/test/ui/closures/2229_closure_analysis/issue-88331.rs b/src/test/ui/closures/2229_closure_analysis/match/issue-88331.rs similarity index 100% rename from src/test/ui/closures/2229_closure_analysis/issue-88331.rs rename to src/test/ui/closures/2229_closure_analysis/match/issue-88331.rs diff --git a/src/test/ui/closures/2229_closure_analysis/issue-88331.stderr b/src/test/ui/closures/2229_closure_analysis/match/issue-88331.stderr similarity index 100% rename from src/test/ui/closures/2229_closure_analysis/issue-88331.stderr rename to src/test/ui/closures/2229_closure_analysis/match/issue-88331.stderr diff --git a/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases.rs b/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_1.rs similarity index 53% rename from src/test/ui/closures/2229_closure_analysis/match/match-edge-cases.rs rename to src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_1.rs index f5330b07445a2..914ebbe26a57d 100644 --- a/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases.rs +++ b/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_1.rs @@ -41,38 +41,4 @@ pub fn edge_case_char(event: char) { }; } -enum SingleVariant { - A -} - -struct TestStruct { - x: i32, - y: i32, - z: i32, -} - -fn edge_case_if() { - let sv = SingleVariant::A; - let condition = true; - // sv should not be captured as it is a SingleVariant - let _a = || { - match sv { - SingleVariant::A if condition => (), - _ => () - } - }; - let mut mut_sv = sv; - _a(); - - // ts should be captured - let ts = TestStruct { x: 1, y: 1, z: 1 }; - let _b = || { match ts { - TestStruct{ x: 1, .. } => (), - _ => () - }}; - let mut mut_ts = ts; - //~^ ERROR: cannot move out of `ts` because it is borrowed - _b(); -} - fn main() {} diff --git a/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_2.rs b/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_2.rs new file mode 100644 index 0000000000000..ae724f9c3cc6f --- /dev/null +++ b/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_2.rs @@ -0,0 +1,37 @@ +// edition:2021 + +enum SingleVariant { + A +} + +struct TestStruct { + x: i32, + y: i32, + z: i32, +} + +fn edge_case_if() { + let sv = SingleVariant::A; + let condition = true; + // sv should not be captured as it is a SingleVariant + let _a = || { + match sv { + SingleVariant::A if condition => (), + _ => () + } + }; + let mut mut_sv = sv; + _a(); + + // ts should be captured + let ts = TestStruct { x: 1, y: 1, z: 1 }; + let _b = || { match ts { + TestStruct{ x: 1, .. } => (), + _ => () + }}; + let mut mut_ts = ts; + //~^ ERROR: cannot move out of `ts` because it is borrowed + _b(); +} + +fn main() {} diff --git a/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases.stderr b/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_2.stderr similarity index 92% rename from src/test/ui/closures/2229_closure_analysis/match/match-edge-cases.stderr rename to src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_2.stderr index b9d2316206ecb..1e42d73c62bd9 100644 --- a/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases.stderr +++ b/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_2.stderr @@ -1,5 +1,5 @@ error[E0505]: cannot move out of `ts` because it is borrowed - --> $DIR/match-edge-cases.rs:32:22 + --> $DIR/match-edge-cases_2.rs:32:22 | LL | let _b = || { match ts { | -- -- borrow occurs due to use in closure