Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5515bba

Browse files
committedJul 7, 2024
Mitigate focused memory leaks in core doctests for Miri.
If/when `-Zmiri-disable-leak-check` is able to be used at test-granularity, it should applied to these tests instead of unleaking.
1 parent 3a0fe26 commit 5515bba

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed
 

‎core/src/mem/manually_drop.rs

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ impl<T> ManuallyDrop<T> {
6262
/// x.truncate(5); // You can still safely operate on the value
6363
/// assert_eq!(*x, "Hello");
6464
/// // But `Drop` will not be run here
65+
/// # // FIXME(https://github.com/rust-lang/miri/issues/3670):
66+
/// # // use -Zmiri-disable-leak-check instead of unleaking in tests meant to leak.
67+
/// # let _ = ManuallyDrop::into_inner(x);
6568
/// ```
6669
#[must_use = "if you don't need the wrapper, you can use `mem::forget` instead"]
6770
#[stable(feature = "manually_drop", since = "1.20.0")]

‎core/src/mem/maybe_uninit.rs

+3
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,9 @@ impl<T> MaybeUninit<T> {
448448
/// let mut x = MaybeUninit::<String>::uninit();
449449
///
450450
/// x.write("Hello".to_string());
451+
/// # // FIXME(https://github.com/rust-lang/miri/issues/3670):
452+
/// # // use -Zmiri-disable-leak-check instead of unleaking in tests meant to leak.
453+
/// # unsafe { MaybeUninit::assume_init_drop(&mut x); }
451454
/// // This leaks the contained string:
452455
/// x.write("hello".to_string());
453456
/// // x is initialized now:

0 commit comments

Comments
 (0)
Failed to load comments.