diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2021-04-04 19:20:06 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-04 19:20:06 +0200 |
| commit | b943ea8cdc677e4637ed25f0d4a2814b168aa97d (patch) | |
| tree | cbc6d077816fc5af9d3c1068c6808543c5fda939 | |
| parent | e62fce32e53478100ef5bffba11fcf4b700849ed (diff) | |
| parent | 572873fce0365cbba75557458ee5d7cb744bac12 (diff) | |
| download | rust-b943ea8cdc677e4637ed25f0d4a2814b168aa97d.tar.gz rust-b943ea8cdc677e4637ed25f0d4a2814b168aa97d.zip | |
Rollup merge of #83827 - the8472:fix-inplace-panic-on-drop, r=RalfJung
cleanup leak after test to make miri happy Contains changes that were requested in #83629 but didn't make it into the rollup. r? `````@RalfJung`````
| -rw-r--r-- | library/alloc/tests/vec.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs index d208bd8ce58..4dcc5d30deb 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs @@ -1078,12 +1078,21 @@ fn test_from_iter_specialization_panic_during_drop_leaks() { } } + let mut to_free: *mut Droppable = core::ptr::null_mut(); + let mut cap = 0; + let _ = std::panic::catch_unwind(AssertUnwindSafe(|| { - let v = vec![Droppable::DroppedTwice(Box::new(123)), Droppable::PanicOnDrop]; + let mut v = vec![Droppable::DroppedTwice(Box::new(123)), Droppable::PanicOnDrop]; + to_free = v.as_mut_ptr(); + cap = v.capacity(); let _ = v.into_iter().take(0).collect::<Vec<_>>(); })); assert_eq!(unsafe { DROP_COUNTER }, 1); + // clean up the leak to keep miri happy + unsafe { + drop(Vec::from_raw_parts(to_free, 0, cap)); + } } #[test] |
