]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/process.rs
Rollup merge of #73955 - hellow554:unsafe_process, r=Mark-Simulacrum
[rust.git] / library / std / src / process.rs
index d1960a049d9062cb01e32b642b2a88e66cfda7fb..00e2dbc9c1dbf33e5d3c7c94c36edf4b6635f762 100644 (file)
@@ -95,6 +95,7 @@
 //! [`Read`]: io::Read
 
 #![stable(feature = "process", since = "1.0.0")]
+#![deny(unsafe_op_in_unsafe_fn)]
 
 #[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten", target_env = "sgx"))))]
 mod tests;
@@ -321,7 +322,8 @@ fn is_read_vectored(&self) -> bool {
 
     #[inline]
     unsafe fn initializer(&self) -> Initializer {
-        Initializer::nop()
+        // SAFETY: Read is guaranteed to work on uninitialized memory
+        unsafe { Initializer::nop() }
     }
 }
 
@@ -381,7 +383,8 @@ fn is_read_vectored(&self) -> bool {
 
     #[inline]
     unsafe fn initializer(&self) -> Initializer {
-        Initializer::nop()
+        // SAFETY: Read is guaranteed to work on uninitialized memory
+        unsafe { Initializer::nop() }
     }
 }