diff options
| author | Ralf Jung <post@ralfj.de> | 2018-11-27 16:12:08 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2018-11-27 16:12:08 +0100 |
| commit | a4f12344c68530d1f42c5b00c10ab417137c0491 (patch) | |
| tree | e524ce93de95033d5cdac8908d6fad6eb4e09968 /src/libcore | |
| parent | 2f2f37983d14c53c3328540d6cf44499c1699521 (diff) | |
add comments explaining our uses of get_ref/get_mut for MaybeUninit
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/fmt/float.rs | 3 | ||||
| -rw-r--r-- | src/libcore/mem.rs | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs index d01cd012031..0c1ac90dfd2 100644 --- a/src/libcore/fmt/float.rs +++ b/src/libcore/fmt/float.rs @@ -22,6 +22,9 @@ fn float_to_decimal_common_exact<T>(fmt: &mut Formatter, num: &T, unsafe { let mut buf = MaybeUninit::<[u8; 1024]>::uninitialized(); // enough for f32 and f64 let mut parts = MaybeUninit::<[flt2dec::Part; 4]>::uninitialized(); + // FIXME: Technically, this is calling `get_mut` on an uninitialized + // `MaybeUninit` (here and elsewhere in this file). Revisit this once + // we decided whether that is valid or not. let formatted = flt2dec::to_exact_fixed_str(flt2dec::strategy::grisu::format_exact, *num, sign, precision, false, buf.get_mut(), parts.get_mut()); diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index a5603ff6a62..626db7806df 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -1106,6 +1106,9 @@ impl<T> MaybeUninit<T> { /// /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized /// state, otherwise this will immediately cause undefined behavior. + // FIXME: We currently rely on the above being incorrect, i.e., we have references + // to uninitialized data (e.g. in `libstd/sys/windows/mutex.rs`). We should make + // a final decision about the rules before stabilization. #[unstable(feature = "maybe_uninit", issue = "53491")] #[inline(always)] pub unsafe fn get_ref(&self) -> &T { @@ -1118,6 +1121,9 @@ impl<T> MaybeUninit<T> { /// /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized /// state, otherwise this will immediately cause undefined behavior. + // FIXME: We currently rely on the above being incorrect, i.e., we have references + // to uninitialized data (e.g. in `libcore/fmt/float.rs`). We should make + // a final decision about the rules before stabilization. #[unstable(feature = "maybe_uninit", issue = "53491")] #[inline(always)] pub unsafe fn get_mut(&mut self) -> &mut T { |
