We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 473b8e1 + 572873f commit 60a8be9Copy full SHA for 60a8be9
library/alloc/tests/vec.rs
@@ -1078,12 +1078,21 @@ fn test_from_iter_specialization_panic_during_drop_leaks() {
1078
}
1079
1080
1081
+ let mut to_free: *mut Droppable = core::ptr::null_mut();
1082
+ let mut cap = 0;
1083
+
1084
let _ = std::panic::catch_unwind(AssertUnwindSafe(|| {
- 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();
1088
let _ = v.into_iter().take(0).collect::<Vec<_>>();
1089
}));
1090
1091
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
+ }
1096
1097
1098
#[test]
0 commit comments