about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTrevor Gross <t.gross35@gmail.com>2024-07-16 20:10:13 -0500
committerGitHub <noreply@github.com>2024-07-16 20:10:13 -0500
commitdd80a728ccb4c9337a5166f21adac7c9a699bb13 (patch)
tree5b9fc07530bee6827c10013a16f96ddd567302df
parent446e0177ec801df4fcc1a4ead29e4956fc809a71 (diff)
parente48d33e18a1b34d2d66fa1f917d639cef4f63a18 (diff)
downloadrust-dd80a728ccb4c9337a5166f21adac7c9a699bb13.tar.gz
rust-dd80a728ccb4c9337a5166f21adac7c9a699bb13.zip
Rollup merge of #127833 - risc0:erik/zkvm-deny-unsafe, r=workingjubilee
zkvm: add `#[forbid(unsafe_op_in_unsafe_fn)]` in `stdlib`

This also adds an additional `unsafe` block to address compiler errors.
This PR is intended to address https://github.com/rust-lang/rust/issues/127747 for the zkvm target.
-rw-r--r--library/std/src/sys/pal/zkvm/alloc.rs2
-rw-r--r--library/std/src/sys/pal/zkvm/mod.rs1
2 files changed, 2 insertions, 1 deletions
diff --git a/library/std/src/sys/pal/zkvm/alloc.rs b/library/std/src/sys/pal/zkvm/alloc.rs
index fd333f12151..2fdca223524 100644
--- a/library/std/src/sys/pal/zkvm/alloc.rs
+++ b/library/std/src/sys/pal/zkvm/alloc.rs
@@ -5,7 +5,7 @@ use crate::alloc::{GlobalAlloc, Layout, System};
 unsafe impl GlobalAlloc for System {
     #[inline]
     unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
-        abi::sys_alloc_aligned(layout.size(), layout.align())
+        unsafe { abi::sys_alloc_aligned(layout.size(), layout.align()) }
     }
 
     #[inline]
diff --git a/library/std/src/sys/pal/zkvm/mod.rs b/library/std/src/sys/pal/zkvm/mod.rs
index bacde9d880c..651f25d6623 100644
--- a/library/std/src/sys/pal/zkvm/mod.rs
+++ b/library/std/src/sys/pal/zkvm/mod.rs
@@ -6,6 +6,7 @@
 //! This is all super highly experimental and not actually intended for
 //! wide/production use yet, it's still all in the experimental category. This
 //! will likely change over time.
+#![forbid(unsafe_op_in_unsafe_fn)]
 
 const WORD_SIZE: usize = core::mem::size_of::<u32>();