Skip to content

Commit 5515bba

Browse files
committed
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy