Rollup merge of #73962 - ryr3:unsafe_tcp, r=LukasKalbertodt

libstd/net/tcp.rs: #![deny(unsafe_op_in_unsafe_fn)]

Enclose unsafe operations in unsafe blocks for net/tcp.rs. Fixes part of #73904.
This commit is contained in:
Manish Goregaokar 2020-07-06 17:45:24 -07:00 committed by GitHub
commit ca5b64d2d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
#![deny(unsafe_op_in_unsafe_fn)]
use crate::io::prelude::*;
use crate::fmt;
@ -583,7 +584,8 @@ impl Read for TcpStream {
#[inline]
unsafe fn initializer(&self) -> Initializer {
Initializer::nop()
// SAFETY: Read is guaranteed to work on uninitialized memory
unsafe { Initializer::nop() }
}
}
#[stable(feature = "rust1", since = "1.0.0")]
@ -622,7 +624,8 @@ impl Read for &TcpStream {
#[inline]
unsafe fn initializer(&self) -> Initializer {
Initializer::nop()
// SAFETY: Read is guaranteed to work on uninitialized memory
unsafe { Initializer::nop() }
}
}
#[stable(feature = "rust1", since = "1.0.0")]