Skip to content

Commit 60a8be9

Browse files
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``
2 parents 473b8e1 + 572873f commit 60a8be9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

library/alloc/tests/vec.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -1078,12 +1078,21 @@ fn test_from_iter_specialization_panic_during_drop_leaks() {
10781078
}
10791079
}
10801080

1081+
let mut to_free: *mut Droppable = core::ptr::null_mut();
1082+
let mut cap = 0;
1083+
10811084
let _ = std::panic::catch_unwind(AssertUnwindSafe(|| {
1082-
let v = vec![Droppable::DroppedTwice(Box::new(123)), Droppable::PanicOnDrop];
1085+
let mut v = vec![Droppable::DroppedTwice(Box::new(123)), Droppable::PanicOnDrop];
1086+
to_free = v.as_mut_ptr();
1087+
cap = v.capacity();
10831088
let _ = v.into_iter().take(0).collect::<Vec<_>>();
10841089
}));
10851090

10861091
assert_eq!(unsafe { DROP_COUNTER }, 1);
1092+
// clean up the leak to keep miri happy
1093+
unsafe {
1094+
drop(Vec::from_raw_parts(to_free, 0, cap));
1095+
}
10871096
}
10881097

10891098
#[test]

0 commit comments

Comments
 (0)