diff --git a/crates/polkavm/src/api.rs b/crates/polkavm/src/api.rs index 5b65f7e1..17cd13b2 100644 --- a/crates/polkavm/src/api.rs +++ b/crates/polkavm/src/api.rs @@ -1,6 +1,9 @@ -use alloc::borrow::{Cow, ToOwned}; +use alloc::borrow::Cow; +#[cfg(not(feature = "std"))] +use alloc::borrow::ToOwned; use alloc::format; use alloc::sync::Arc; +#[cfg(not(feature = "std"))] use alloc::vec::Vec; #[cfg(not(feature = "std"))] @@ -62,6 +65,7 @@ pub(crate) struct EngineState { } pub struct Engine { + #[allow(dead_code)] selected_backend: BackendKind, #[allow(dead_code)] selected_sandbox: Option, @@ -1727,6 +1731,7 @@ pub(crate) struct ExecuteArgs<'a> { pub(crate) flags: u32, pub(crate) hostcall_handler: Option>, pub(crate) module: Option<&'a Module>, + #[allow(dead_code)] pub(crate) is_async: bool, } diff --git a/crates/polkavm/src/caller.rs b/crates/polkavm/src/caller.rs index da048c51..9c13e502 100644 --- a/crates/polkavm/src/caller.rs +++ b/crates/polkavm/src/caller.rs @@ -2,6 +2,7 @@ use crate::api::BackendAccess; use crate::tracer::Tracer; use crate::Gas; use alloc::rc::{Rc, Weak}; +#[cfg(not(feature = "std"))] use alloc::vec::Vec; use core::mem::MaybeUninit; use polkavm_common::error::Trap; diff --git a/crates/polkavm/src/config.rs b/crates/polkavm/src/config.rs index 07117ae0..8540c216 100644 --- a/crates/polkavm/src/config.rs +++ b/crates/polkavm/src/config.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "std")] use crate::error::{bail, Error}; #[derive(Copy, Clone, PartialEq, Eq, Debug)] diff --git a/crates/polkavm/src/error.rs b/crates/polkavm/src/error.rs index bf21cf7d..64d31796 100644 --- a/crates/polkavm/src/error.rs +++ b/crates/polkavm/src/error.rs @@ -1,4 +1,5 @@ use alloc::format; +#[cfg(not(feature = "std"))] use alloc::string::{String, ToString}; use polkavm_common::program::ProgramParseError; @@ -73,6 +74,7 @@ impl Error { } #[cold] + #[allow(dead_code)] pub(crate) fn context(self, message: impl core::fmt::Display) -> Self { let string = match self.0 { ErrorKind::Owned(mut buffer) => { diff --git a/crates/polkavm/src/gas.rs b/crates/polkavm/src/gas.rs index 8343940b..2f954315 100644 --- a/crates/polkavm/src/gas.rs +++ b/crates/polkavm/src/gas.rs @@ -15,6 +15,7 @@ impl GasVisitor { } #[inline] + #[allow(dead_code)] pub fn take_block_cost(&mut self) -> Option { self.last_block_cost.take() } diff --git a/crates/polkavm/src/interpreter.rs b/crates/polkavm/src/interpreter.rs index 3b699618..69581bc3 100644 --- a/crates/polkavm/src/interpreter.rs +++ b/crates/polkavm/src/interpreter.rs @@ -2,6 +2,7 @@ use crate::api::{BackendAccess, ExecuteArgs, HostcallHandler, MemoryAccessError, use crate::error::Error; use crate::utils::GuestInit; use crate::utils::{FlatMap, RegImm}; +#[cfg(not(feature = "std"))] use alloc::vec::Vec; use core::mem::MaybeUninit; use core::num::NonZeroU32; diff --git a/crates/polkavm/src/tracer.rs b/crates/polkavm/src/tracer.rs index 5628306c..8282b5bf 100644 --- a/crates/polkavm/src/tracer.rs +++ b/crates/polkavm/src/tracer.rs @@ -152,7 +152,7 @@ impl Tracer { fn trace_current_instruction_source(&mut self, program_counter: u32) { #[cfg(not(windows))] const VT_DARK: &str = "\x1B[1;30m"; - #[cfg(not(windows))] + #[cfg(all(not(windows), feature = "std"))] const VT_GREEN: &str = "\x1B[1;32m"; #[cfg(not(windows))] const VT_RESET: &str = "\x1B[0m"; @@ -258,10 +258,13 @@ impl Tracer { } self.current_source_location = location_ref; - let Some((path_offset, line)) = location_ref else { + #[cfg(feature = "std")] + let Some((path_offset, line)) = location_ref + else { return; }; + #[cfg(feature = "std")] let Ok(path) = self.module.get_debug_string(path_offset) else { return; }; diff --git a/crates/polkavm/src/utils.rs b/crates/polkavm/src/utils.rs index aaf1cf45..5ae3b9ec 100644 --- a/crates/polkavm/src/utils.rs +++ b/crates/polkavm/src/utils.rs @@ -1,3 +1,4 @@ +#[cfg(not(feature = "std"))] use alloc::vec::Vec; use polkavm_common::program::RawReg; @@ -54,6 +55,7 @@ where } #[inline] + #[allow(dead_code)] pub fn new_reusing_memory(mut memory: Self, capacity: u32) -> Self { memory.inner.clear(); memory.inner.resize_with(capacity as usize, || None); @@ -66,6 +68,7 @@ where } #[inline] + #[allow(dead_code)] pub fn len(&self) -> u32 { self.inner.len() as u32 } @@ -76,6 +79,7 @@ where } #[inline] + #[allow(dead_code)] pub fn clear(&mut self) { self.inner.clear(); }