diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-07-06 17:45:24 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-06 17:45:24 -0700 |
| commit | ca5b64d2d28daa900942a51854727205719c9028 (patch) | |
| tree | f3fe0c75333c2fa2df0d91f165d6e5cd0fcb3bf1 /src/libstd | |
| parent | e74ab50d07a8b21e8d03ebfb0da8dae6583b1e67 (diff) | |
| parent | 8dc1e42515adbf0946a235b464b2fd41619cec04 (diff) | |
| download | rust-ca5b64d2d28daa900942a51854727205719c9028.tar.gz rust-ca5b64d2d28daa900942a51854727205719c9028.zip | |
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.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/net/tcp.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 9ac54dd5f7a..47b8532b7a6 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -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")] |
