]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/sys/hermit/thread.rs
`#![deny(unsafe_op_in_unsafe_fn)]` in sys/hermit
[rust.git] / library / std / src / sys / hermit / thread.rs
index e11afed668728f08abe9be030ca22af6f231bab7..7c52112a80c2d299eceb28955217fef13b29452d 100644 (file)
@@ -1,4 +1,5 @@
 #![allow(dead_code)]
+#![deny(unsafe_op_in_unsafe_fn)]
 
 use crate::ffi::CStr;
 use crate::io;
@@ -25,18 +26,22 @@ pub unsafe fn new_with_coreid(
         core_id: isize,
     ) -> io::Result<Thread> {
         let p = Box::into_raw(box p);
-        let tid = abi::spawn2(
-            thread_start,
-            p as usize,
-            abi::Priority::into(abi::NORMAL_PRIO),
-            stack,
-            core_id,
-        );
+        let tid = unsafe {
+            abi::spawn2(
+                thread_start,
+                p as usize,
+                abi::Priority::into(abi::NORMAL_PRIO),
+                stack,
+                core_id,
+            )
+        };
 
         return if tid == 0 {
             // The thread failed to start and as a result p was not consumed. Therefore, it is
             // safe to reconstruct the box so that it gets deallocated.
-            drop(Box::from_raw(p));
+            unsafe {
+                drop(Box::from_raw(p));
+            }
             Err(io::Error::new(io::ErrorKind::Other, "Unable to create thread!"))
         } else {
             Ok(Thread { tid: tid })