Skip to content

Commit

Permalink
Rollup merge of rust-lang#73962 - ryr3:unsafe_tcp, r=LukasKalbertodt
Browse files Browse the repository at this point in the history
libstd/net/tcp.rs: #![deny(unsafe_op_in_unsafe_fn)]

Enclose unsafe operations in unsafe blocks for net/tcp.rs. Fixes part of rust-lang#73904.
  • Loading branch information
Manishearth committed Jul 6, 2020
2 parents c6e7035 + 8dc1e42 commit 6f52496
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/libstd/net/tcp.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![deny(unsafe_op_in_unsafe_fn)]
use crate::io::prelude::*;

use crate::fmt;
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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")]
Expand Down

0 comments on commit 6f52496

Please sign in to comment.