diff --git a/library/std/src/io/util.rs b/library/std/src/io/util.rs index 0d4fd5fedf7..c1300cd67c0 100644 --- a/library/std/src/io/util.rs +++ b/library/std/src/io/util.rs @@ -131,12 +131,14 @@ impl Read for Repeat { } fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> io::Result<()> { + // SAFETY: No uninit bytes are being written for slot in unsafe { buf.unfilled_mut() } { slot.write(self.byte); } let remaining = buf.remaining(); + // SAFETY: the entire unfilled portion of buf has been initialized unsafe { buf.assume_init(remaining); }