about summary refs log tree commit diff
path: root/src/test/ui/drop
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2019-11-22 23:15:11 +0000
committerMatthew Jasper <mjjasper1@gmail.com>2019-12-09 20:43:24 +0000
commitd96485d49e3745a9b9f4b2ed6ba9cebf265f142e (patch)
treeef52ff1543d7f312ffdc43a58ef9fb3f8798e11a /src/test/ui/drop
parentcab7af986c8662d68213b9577c251036b4cbcb71 (diff)
downloadrust-d96485d49e3745a9b9f4b2ed6ba9cebf265f142e.tar.gz
rust-d96485d49e3745a9b9f4b2ed6ba9cebf265f142e.zip
Add more tests for borrowck and dropck slice pattern handling
Diffstat (limited to 'src/test/ui/drop')
-rw-r--r--src/test/ui/drop/dynamic-drop.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/ui/drop/dynamic-drop.rs b/src/test/ui/drop/dynamic-drop.rs
index 29dcbfe9609..0f0ec0ba460 100644
--- a/src/test/ui/drop/dynamic-drop.rs
+++ b/src/test/ui/drop/dynamic-drop.rs
@@ -269,6 +269,28 @@ fn subslice_pattern_reassign(a: &Allocator) {
     let[_, _y @ ..] = ar;
 }
 
+fn index_field_mixed_ends(a: &Allocator) {
+    let ar = [(a.alloc(), a.alloc()), (a.alloc(), a.alloc())];
+    let[(_x, _), ..] = ar;
+    let[(_, _y), _] = ar;
+    let[_, (_, _w)] = ar;
+    let[.., (_z, _)] = ar;
+}
+
+fn subslice_mixed_min_lengths(a: &Allocator, c: i32) {
+    let ar = [(a.alloc(), a.alloc()), (a.alloc(), a.alloc())];
+    match c {
+        0 => { let[_x, ..] = ar; }
+        1 => { let[_x, _, ..] = ar; }
+        2 => { let[_x, _] = ar; }
+        3 => { let[(_x, _), _, ..] = ar; }
+        4 => { let[.., (_x, _)] = ar; }
+        5 => { let[.., (_x, _), _] = ar; }
+        6 => { let [_y @ ..] = ar; }
+        _ => { let [_y @ .., _] = ar; }
+    }
+}
+
 fn panic_after_return(a: &Allocator) -> Ptr<'_> {
     // Panic in the drop of `p` or `q` can leak
     let exceptions = vec![8, 9];
@@ -422,6 +444,16 @@ fn main() {
     run_test(|a| slice_pattern_reassign(a));
     run_test(|a| subslice_pattern_reassign(a));
 
+    run_test(|a| index_field_mixed_ends(a));
+    run_test(|a| subslice_mixed_min_lengths(a, 0));
+    run_test(|a| subslice_mixed_min_lengths(a, 1));
+    run_test(|a| subslice_mixed_min_lengths(a, 2));
+    run_test(|a| subslice_mixed_min_lengths(a, 3));
+    run_test(|a| subslice_mixed_min_lengths(a, 4));
+    run_test(|a| subslice_mixed_min_lengths(a, 5));
+    run_test(|a| subslice_mixed_min_lengths(a, 6));
+    run_test(|a| subslice_mixed_min_lengths(a, 7));
+
     run_test(|a| {
         panic_after_return(a);
     });