about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-12-02 13:45:22 +0000
committerbors <bors@rust-lang.org>2018-12-02 13:45:22 +0000
commit8660eba2b9bec5b0fe971b7281f79e79c2df2fae (patch)
tree86a0f14bde134d8357458c80472b51204d489b5d /src/libcore
parent9abc2312124de7c4275d76e9cbc81d50086c4768 (diff)
parentebe69c06b38e0d1d20c79ee4342715514e917107 (diff)
downloadrust-8660eba2b9bec5b0fe971b7281f79e79c2df2fae.tar.gz
rust-8660eba2b9bec5b0fe971b7281f79e79c2df2fae.zip
Auto merge of #56275 - RalfJung:win-mutex, r=SimonSapin
use MaybeUninit instead of mem::uninitialized for Windows Mutex

I hope this builds, I do not have a Windows machine to test...
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/fmt/float.rs3
-rw-r--r--src/libcore/mem.rs3
2 files changed, 6 insertions, 0 deletions
diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs
index d01cd012031..3717a783f24 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(#53491): 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..e4b2800ae21 100644
--- a/src/libcore/mem.rs
+++ b/src/libcore/mem.rs
@@ -1118,6 +1118,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(#53491): 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 {