Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy fix #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/polkavm/src/api.rs
Original file line number Diff line number Diff line change
@@ -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"))]
Expand Down Expand Up @@ -62,6 +65,7 @@ pub(crate) struct EngineState {
}

pub struct Engine {
#[allow(dead_code)]
selected_backend: BackendKind,
#[allow(dead_code)]
selected_sandbox: Option<SandboxKind>,
Expand Down Expand Up @@ -1727,6 +1731,7 @@ pub(crate) struct ExecuteArgs<'a> {
pub(crate) flags: u32,
pub(crate) hostcall_handler: Option<HostcallHandler<'a>>,
pub(crate) module: Option<&'a Module>,
#[allow(dead_code)]
pub(crate) is_async: bool,
}

Expand Down
1 change: 1 addition & 0 deletions crates/polkavm/src/caller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions crates/polkavm/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(feature = "std")]
use crate::error::{bail, Error};

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
Expand Down
2 changes: 2 additions & 0 deletions crates/polkavm/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloc::format;
#[cfg(not(feature = "std"))]
use alloc::string::{String, ToString};
use polkavm_common::program::ProgramParseError;

Expand Down Expand Up @@ -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) => {
Expand Down
1 change: 1 addition & 0 deletions crates/polkavm/src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ impl GasVisitor {
}

#[inline]
#[allow(dead_code)]
pub fn take_block_cost(&mut self) -> Option<u32> {
self.last_block_cost.take()
}
Expand Down
1 change: 1 addition & 0 deletions crates/polkavm/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions crates/polkavm/src/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
};
Expand Down
4 changes: 4 additions & 0 deletions crates/polkavm/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use polkavm_common::program::RawReg;

Expand Down Expand Up @@ -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);
Expand All @@ -66,6 +68,7 @@ where
}

#[inline]
#[allow(dead_code)]
pub fn len(&self) -> u32 {
self.inner.len() as u32
}
Expand All @@ -76,6 +79,7 @@ where
}

#[inline]
#[allow(dead_code)]
pub fn clear(&mut self) {
self.inner.clear();
}
Expand Down