about summary refs log tree commit diff
path: root/src/liballoc/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-12-13 19:39:20 +0000
committerbors <bors@rust-lang.org>2019-12-13 19:39:20 +0000
commitff15e9670843f8bd6b54ab1b042d2095b4c0aa6d (patch)
treeab93656235150d2f5d3104ec4d0de0004581a89b /src/liballoc/tests
parent703c82e5319c15929df38bb8611755b3eda5bd8e (diff)
parentd0cc289ec0fa35de2aa35df5445ebca332ccf4f6 (diff)
downloadrust-ff15e9670843f8bd6b54ab1b042d2095b4c0aa6d.tar.gz
rust-ff15e9670843f8bd6b54ab1b042d2095b4c0aa6d.zip
Auto merge of #67284 - Centril:rollup-ghiukob, r=Centril
Rollup of 7 pull requests

Successful merges:

 - #67026 (Improve diagnostics and code for exhaustiveness of empty matches)
 - #67235 (VecDeque: drop remaining items on destructor panic)
 - #67254 (dont ICE in case of invalid drop fn)
 - #67256 (Reduce allocs for validation errors)
 - #67274 (be explicit that mem::uninitialized is the same as MaybeUninit::uninit().assume_init())
 - #67278 (`coerce_inner`: use initial `expected_ty`)
 - #67280 (docs: std::convert::From: Fix typo)

Failed merges:

r? @ghost
Diffstat (limited to 'src/liballoc/tests')
-rw-r--r--src/liballoc/tests/vec_deque.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/liballoc/tests/vec_deque.rs b/src/liballoc/tests/vec_deque.rs
index ebcc8320171..1ab3694a3ca 100644
--- a/src/liballoc/tests/vec_deque.rs
+++ b/src/liballoc/tests/vec_deque.rs
@@ -2,6 +2,7 @@ use std::collections::TryReserveError::*;
 use std::collections::{vec_deque::Drain, VecDeque};
 use std::fmt::Debug;
 use std::mem::size_of;
+use std::panic::catch_unwind;
 use std::{isize, usize};
 
 use crate::hash;
@@ -710,6 +711,39 @@ fn test_drop_clear() {
 }
 
 #[test]
+fn test_drop_panic() {
+    static mut DROPS: i32 = 0;
+
+    struct D(bool);
+
+    impl Drop for D {
+        fn drop(&mut self) {
+            unsafe {
+                DROPS += 1;
+            }
+
+            if self.0 {
+                panic!("panic in `drop`");
+            }
+        }
+    }
+
+    let mut q = VecDeque::new();
+    q.push_back(D(false));
+    q.push_back(D(false));
+    q.push_back(D(false));
+    q.push_back(D(false));
+    q.push_back(D(false));
+    q.push_front(D(false));
+    q.push_front(D(false));
+    q.push_front(D(true));
+
+    catch_unwind(move || drop(q)).ok();
+
+    assert_eq!(unsafe { DROPS }, 8);
+}
+
+#[test]
 fn test_reserve_grow() {
     // test growth path A
     // [T o o H] -> [T o o H . . . . ]