Skip to content

Commit

Permalink
Rollup merge of #76242 - RalfJung:read-fixme, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Read: adjust a FIXME reference

There's already another reference to #42788 for basically the same problem, so lets reuse it here:
https://github.com/rust-lang/rust/blob/5e208efaa850efaa97495e81c49cf0f5767e8f49/library/std/src/io/mod.rs#L369-L376

r? @Dylan-DPC
  • Loading branch information
Dylan-DPC authored Sep 3, 2020
2 parents 4918ed9 + 0af3bd0 commit 6d2b885
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions library/std/src/io/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ where
W: Write,
{
let mut buf = MaybeUninit::<[u8; super::DEFAULT_BUF_SIZE]>::uninit();
// FIXME(#76092): This is calling `get_mut` and `get_ref` on an uninitialized
// `MaybeUninit`. Revisit this once we decided whether that is valid or not.
// This is still technically undefined behavior due to creating a reference
// to uninitialized data, but within libstd we can rely on more guarantees
// than if this code were in an external lib.
// FIXME: #42788
//
// - This creates a (mut) reference to a slice of
// _uninitialized_ integers, which is **undefined behavior**
//
// - Only the standard library gets to soundly "ignore" this,
// based on its privileged knowledge of unstable rustc
// internals;
unsafe {
reader.initializer().initialize(buf.assume_init_mut());
}
Expand Down

0 comments on commit 6d2b885

Please sign in to comment.