]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #73955 - hellow554:unsafe_process, r=Mark-Simulacrum
authorDylan DPC <dylan.dpc@gmail.com>
Tue, 15 Sep 2020 23:30:28 +0000 (01:30 +0200)
committerGitHub <noreply@github.com>
Tue, 15 Sep 2020 23:30:28 +0000 (01:30 +0200)
deny(unsafe_op_in_unsafe_fn) in libstd/process.rs

The libstd/process.rs part of #73904 . Wraps the two calls to an unsafe fn Initializer::nop() in an unsafe block.

Will have to wait for #73909 to be merged, because of the feature in the libstd/lib.rs

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() }
     }
 }