summaryrefslogtreecommitdiffstats
path: root/src/test/ui/borrowck/borrowck-closures-slice-patterns-ok.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /src/test/ui/borrowck/borrowck-closures-slice-patterns-ok.rs
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/borrowck/borrowck-closures-slice-patterns-ok.rs')
-rw-r--r--src/test/ui/borrowck/borrowck-closures-slice-patterns-ok.rs117
1 files changed, 0 insertions, 117 deletions
diff --git a/src/test/ui/borrowck/borrowck-closures-slice-patterns-ok.rs b/src/test/ui/borrowck/borrowck-closures-slice-patterns-ok.rs
deleted file mode 100644
index 0229ca37a..000000000
--- a/src/test/ui/borrowck/borrowck-closures-slice-patterns-ok.rs
+++ /dev/null
@@ -1,117 +0,0 @@
-// Check that closure captures for slice patterns are inferred correctly
-
-#![allow(unused_variables)]
-
-// run-pass
-
-fn arr_by_ref(x: [String; 3]) {
- let r = &x;
- let f = || {
- let [ref y, ref z @ ..] = x;
- };
- f();
- f();
- // Ensure `x` was borrowed
- drop(r);
- // Ensure that `x` wasn't moved from.
- drop(x);
-}
-
-fn arr_by_mut(mut x: [String; 3]) {
- let mut f = || {
- let [ref mut y, ref mut z @ ..] = x;
- };
- f();
- f();
- drop(x);
-}
-
-fn arr_by_move(x: [String; 3]) {
- let f = || {
- let [y, z @ ..] = x;
- };
- f();
-}
-
-fn arr_ref_by_ref(x: &[String; 3]) {
- let r = &x;
- let f = || {
- let [ref y, ref z @ ..] = *x;
- };
- let g = || {
- let [y, z @ ..] = x;
- };
- f();
- g();
- f();
- g();
- drop(r);
- drop(x);
-}
-
-fn arr_ref_by_mut(x: &mut [String; 3]) {
- let mut f = || {
- let [ref mut y, ref mut z @ ..] = *x;
- };
- f();
- f();
- let mut g = || {
- let [y, z @ ..] = x;
- // Ensure binding mode was chosen correctly:
- std::mem::swap(y, &mut z[0]);
- };
- g();
- g();
- drop(x);
-}
-
-fn arr_box_by_move(x: Box<[String; 3]>) {
- let f = || {
- let [y, z @ ..] = *x;
- };
- f();
-}
-
-fn slice_by_ref(x: &[String]) {
- let r = &x;
- let f = || {
- if let [ref y, ref z @ ..] = *x {}
- };
- let g = || {
- if let [y, z @ ..] = x {}
- };
- f();
- g();
- f();
- g();
- drop(r);
- drop(x);
-}
-
-fn slice_by_mut(x: &mut [String]) {
- let mut f = || {
- if let [ref mut y, ref mut z @ ..] = *x {}
- };
- f();
- f();
- let mut g = || {
- if let [y, z @ ..] = x {
- // Ensure binding mode was chosen correctly:
- std::mem::swap(y, &mut z[0]);
- }
- };
- g();
- g();
- drop(x);
-}
-
-fn main() {
- arr_by_ref(Default::default());
- arr_by_mut(Default::default());
- arr_by_move(Default::default());
- arr_ref_by_ref(&Default::default());
- arr_ref_by_mut(&mut Default::default());
- arr_box_by_move(Default::default());
- slice_by_ref(&<[_; 3]>::default());
- slice_by_mut(&mut <[_; 3]>::default());
-}