Remove non-focused memory leaks in alloc
doctests for Miri. · model-checking/verify-rust-std@cac8902 (original) (raw)
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1287,6 +1287,8 @@ impl<T: ?Sized> Rc { | ||
1287 | 1287 | /// |
1288 | 1288 | /// let five = Rc::from_raw(ptr); |
1289 | 1289 | /// assert_eq!(2, Rc::strong_count(&five)); |
1290 | + /// # // Prevent leaks for Miri. | |
1291 | + /// # Rc::decrement_strong_count(ptr); | |
1290 | 1292 | /// } |
1291 | 1293 | /// ``` |
1292 | 1294 | #[inline] |
@@ -1344,6 +1346,8 @@ impl<T: ?Sized, A: Allocator> Rc<T, A> { | ||
1344 | 1346 | /// let x = Rc::new("hello".to_owned()); |
1345 | 1347 | /// let x_ptr = Rc::into_raw(x); |
1346 | 1348 | /// assert_eq!(unsafe { &*x_ptr }, "hello"); |
1349 | + /// # // Prevent leaks for Miri. | |
1350 | + /// # drop(unsafe { Rc::from_raw(x_ptr) }); | |
1347 | 1351 | /// ``` |
1348 | 1352 | #[must_use = "losing the pointer will leak memory"] |
1349 | 1353 | #[stable(feature = "rc_raw", since = "1.17.0")] |
@@ -1571,6 +1575,8 @@ impl<T: ?Sized, A: Allocator> Rc<T, A> { | ||
1571 | 1575 | /// |
1572 | 1576 | /// let five = Rc::from_raw_in(ptr, System); |
1573 | 1577 | /// assert_eq!(2, Rc::strong_count(&five)); |
1578 | + /// # // Prevent leaks for Miri. | |
1579 | + /// # Rc::decrement_strong_count_in(ptr, System); | |
1574 | 1580 | /// } |
1575 | 1581 | /// ``` |
1576 | 1582 | #[inline] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1428,6 +1428,8 @@ impl<T: ?Sized> Arc { | ||
1428 | 1428 | /// // the `Arc` between threads. |
1429 | 1429 | /// let five = Arc::from_raw(ptr); |
1430 | 1430 | /// assert_eq!(2, Arc::strong_count(&five)); |
1431 | + /// # // Prevent leaks for Miri. | |
1432 | + /// # Arc::decrement_strong_count(ptr); | |
1431 | 1433 | /// } |
1432 | 1434 | /// ``` |
1433 | 1435 | #[inline] |
@@ -1487,6 +1489,8 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> { | ||
1487 | 1489 | /// let x = Arc::new("hello".to_owned()); |
1488 | 1490 | /// let x_ptr = Arc::into_raw(x); |
1489 | 1491 | /// assert_eq!(unsafe { &*x_ptr }, "hello"); |
1492 | + /// # // Prevent leaks for Miri. | |
1493 | + /// # drop(unsafe { Arc::from_raw(x_ptr) }); | |
1490 | 1494 | /// ``` |
1491 | 1495 | #[must_use = "losing the pointer will leak memory"] |
1492 | 1496 | #[stable(feature = "rc_raw", since = "1.17.0")] |
@@ -1769,6 +1773,8 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> { | ||
1769 | 1773 | /// // the `Arc` between threads. |
1770 | 1774 | /// let five = Arc::from_raw_in(ptr, System); |
1771 | 1775 | /// assert_eq!(2, Arc::strong_count(&five)); |
1776 | + /// # // Prevent leaks for Miri. | |
1777 | + /// # Arc::decrement_strong_count_in(ptr, System); | |
1772 | 1778 | /// } |
1773 | 1779 | /// ``` |
1774 | 1780 | #[inline] |