]> git.proxmox.com Git - rustc.git/blobdiff - library/core/tests/iter/adapters/zip.rs
New upstream version 1.55.0+dfsg1
[rustc.git] / library / core / tests / iter / adapters / zip.rs
index 797bfd957f906ec2cc4c28632cc621e0b3f1fcc2..585cfbb90e40c1d3cfcd5d1718b0f77d7765d1c3 100644 (file)
@@ -232,6 +232,33 @@ fn test_zip_trusted_random_access_composition() {
     assert_eq!(z2.next().unwrap(), ((1, 1), 1));
 }
 
+#[test]
+#[cfg(panic = "unwind")]
+fn test_zip_trusted_random_access_next_back_drop() {
+    use std::panic::catch_unwind;
+    use std::panic::AssertUnwindSafe;
+
+    let mut counter = 0;
+
+    let it = [42].iter().map(|e| {
+        let c = counter;
+        counter += 1;
+        if c == 0 {
+            panic!("bomb");
+        }
+
+        e
+    });
+    let it2 = [(); 0].iter();
+    let mut zip = it.zip(it2);
+    catch_unwind(AssertUnwindSafe(|| {
+        zip.next_back();
+    }))
+    .unwrap_err();
+    assert!(zip.next().is_none());
+    assert_eq!(counter, 1);
+}
+
 #[test]
 fn test_double_ended_zip() {
     let xs = [1, 2, 3, 4, 5, 6];