summaryrefslogtreecommitdiffstats
path: root/tests/ui/borrowck/borrowck-move-out-from-array-use-no-overlap.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 /tests/ui/borrowck/borrowck-move-out-from-array-use-no-overlap.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 'tests/ui/borrowck/borrowck-move-out-from-array-use-no-overlap.rs')
-rw-r--r--tests/ui/borrowck/borrowck-move-out-from-array-use-no-overlap.rs67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrowck-move-out-from-array-use-no-overlap.rs b/tests/ui/borrowck/borrowck-move-out-from-array-use-no-overlap.rs
new file mode 100644
index 000000000..e3498cef3
--- /dev/null
+++ b/tests/ui/borrowck/borrowck-move-out-from-array-use-no-overlap.rs
@@ -0,0 +1,67 @@
+// check-pass
+
+fn array() -> [(String, String); 3] {
+ Default::default()
+}
+
+// Const Index + Const Index
+
+fn move_out_from_begin_and_one_from_end() {
+ let a = array();
+ let [_, _, _x] = a;
+ let [.., ref _y, _] = a;
+}
+
+fn move_out_from_begin_field_and_end_field() {
+ let a = array();
+ let [_, _, (_x, _)] = a;
+ let [.., (_, ref _y)] = a;
+}
+
+// Const Index + Slice
+
+fn move_out_by_const_index_and_subslice() {
+ let a = array();
+ let [_x, _, _] = a;
+ let [_, ref _y @ ..] = a;
+}
+
+fn move_out_by_const_index_end_and_subslice() {
+ let a = array();
+ let [.., _x] = a;
+ let [ref _y @ .., _] = a;
+}
+
+fn move_out_by_const_index_field_and_subslice() {
+ let a = array();
+ let [(_x, _), _, _] = a;
+ let [_, ref _y @ ..] = a;
+}
+
+fn move_out_by_const_index_end_field_and_subslice() {
+ let a = array();
+ let [.., (_x, _)] = a;
+ let [ref _y @ .., _] = a;
+}
+
+fn move_out_by_const_subslice_and_index_field() {
+ let a = array();
+ let [_, _y @ ..] = a;
+ let [(ref _x, _), _, _] = a;
+}
+
+fn move_out_by_const_subslice_and_end_index_field() {
+ let a = array();
+ let [_y @ .., _] = a;
+ let [.., (ref _x, _)] = a;
+}
+
+// Slice + Slice
+
+fn move_out_by_subslice_and_subslice() {
+ let a = array();
+ let [x @ .., _, _] = a;
+ let [_, ref _y @ ..] = a;
+}
+
+fn main() {}