From f8fd9d1d2a2a4fdafeea5c304934da2da33fca22 Mon Sep 17 00:00:00 2001 From: Robin Freyler Date: Tue, 18 Jun 2024 10:43:09 +0200 Subject: [PATCH] Remove unused code and some unused annotations (#1077) * remove unused code * remove unused warnings allowances * add comment to warning allowance --- .../wasmi/src/engine/executor/stack/calls.rs | 3 --- crates/wasmi/src/engine/executor/stack/mod.rs | 20 ------------------- .../wasmi/src/engine/executor/stack/values.rs | 5 ----- .../src/engine/translator/tests/op/mod.rs | 2 +- crates/wasmi/src/func/into_func.rs | 2 -- crates/wasmi/src/store.rs | 1 - fuzz/fuzz_targets/differential.rs | 1 - 7 files changed, 1 insertion(+), 33 deletions(-) diff --git a/crates/wasmi/src/engine/executor/stack/calls.rs b/crates/wasmi/src/engine/executor/stack/calls.rs index 4a47973c44..eb21cdd8f4 100644 --- a/crates/wasmi/src/engine/executor/stack/calls.rs +++ b/crates/wasmi/src/engine/executor/stack/calls.rs @@ -34,9 +34,6 @@ pub struct CallStack { } impl CallStack { - /// Default value for the maximum recursion depth. - pub const DEFAULT_MAX_RECURSION_DEPTH: usize = 1024; - /// Creates a new [`CallStack`] using the given recursion limit. pub fn new(recursion_limit: usize) -> Self { Self { diff --git a/crates/wasmi/src/engine/executor/stack/mod.rs b/crates/wasmi/src/engine/executor/stack/mod.rs index 7a6c1c69c9..33743bfd91 100644 --- a/crates/wasmi/src/engine/executor/stack/mod.rs +++ b/crates/wasmi/src/engine/executor/stack/mod.rs @@ -29,17 +29,6 @@ pub struct Stack { } impl Stack { - #![allow(dead_code)] - - /// Default value for the maximum recursion depth. - pub const DEFAULT_MAX_RECURSION_DEPTH: usize = CallStack::DEFAULT_MAX_RECURSION_DEPTH; - - /// Default value for initial value stack height in bytes. - pub const DEFAULT_MIN_VALUE_STACK_HEIGHT: usize = ValueStack::DEFAULT_MIN_HEIGHT; - - /// Default value for maximum value stack height in bytes. - pub const DEFAULT_MAX_VALUE_STACK_HEIGHT: usize = ValueStack::DEFAULT_MAX_HEIGHT; - /// Creates a new [`Stack`] given the [`Config`]. /// /// [`Config`]: [`crate::Config`] @@ -70,15 +59,6 @@ impl Stack { } } - /// Returns `true` if the [`Stack`] is empty. - /// - /// # Note - /// - /// Empty [`Stack`] instances are usually non-usable dummy instances. - pub fn is_empty(&self) -> bool { - self.values.is_empty() - } - /// Returns the capacity of the [`Stack`]. pub fn capacity(&self) -> usize { self.values.capacity() diff --git a/crates/wasmi/src/engine/executor/stack/values.rs b/crates/wasmi/src/engine/executor/stack/values.rs index e1ab15c4f4..9c388580ef 100644 --- a/crates/wasmi/src/engine/executor/stack/values.rs +++ b/crates/wasmi/src/engine/executor/stack/values.rs @@ -125,11 +125,6 @@ impl ValueStack { self.values.capacity() } - /// Returns `true` if the [`ValueStack`] is empty. - pub fn is_empty(&self) -> bool { - self.len() == 0 - } - /// Reserves enough space for `additional` cells on the [`ValueStack`]. /// /// This may heap allocate in case the [`ValueStack`] ran out of preallocated memory. diff --git a/crates/wasmi/src/engine/translator/tests/op/mod.rs b/crates/wasmi/src/engine/translator/tests/op/mod.rs index bfa5d05c84..6c22eb08ca 100644 --- a/crates/wasmi/src/engine/translator/tests/op/mod.rs +++ b/crates/wasmi/src/engine/translator/tests/op/mod.rs @@ -59,7 +59,7 @@ use std::format; /// /// If the `value` cannot be converted into `i32` losslessly. #[track_caller] -#[allow(dead_code)] +#[allow(dead_code)] // might be useful later fn i32imm16(value: i32) -> Const16 { >::try_from(value) .unwrap_or_else(|_| panic!("value must be 16-bit encodable: {}", value)) diff --git a/crates/wasmi/src/func/into_func.rs b/crates/wasmi/src/func/into_func.rs index bc167f7c0d..d025f03361 100644 --- a/crates/wasmi/src/func/into_func.rs +++ b/crates/wasmi/src/func/into_func.rs @@ -328,7 +328,6 @@ mod tests { marker: core::marker::PhantomData T>, } /// Utility trait for the fallback case of the `implements_wasm_results` macro. - #[allow(dead_code)] // TODO: somehow the tests work without this which is strange. pub trait ImplementsWasmRetFallback { const VALUE: bool = false; } @@ -341,7 +340,6 @@ mod tests { // We need to allow for dead code at this point because // the Rust compiler thinks this function is unused even // though it acts as the specialized case for detection. - #[allow(dead_code)] pub const VALUE: bool = true; } /// Returns `true` if the given type `T` implements the `WasmRet` trait. diff --git a/crates/wasmi/src/store.rs b/crates/wasmi/src/store.rs index 4d46857d29..b4acf973f2 100644 --- a/crates/wasmi/src/store.rs +++ b/crates/wasmi/src/store.rs @@ -684,7 +684,6 @@ impl StoreInner { /// /// - If the [`ElementSegment`] does not originate from this [`Store`]. /// - If the [`ElementSegment`] cannot be resolved to its entity. - #[allow(unused)] // Note: We allow this unused API to exist to uphold code symmetry. pub fn resolve_element_segment(&self, segment: &ElementSegment) -> &ElementSegmentEntity { self.resolve(segment.as_inner(), &self.elems) } diff --git a/fuzz/fuzz_targets/differential.rs b/fuzz/fuzz_targets/differential.rs index b64c8185b7..ada43f5b69 100644 --- a/fuzz/fuzz_targets/differential.rs +++ b/fuzz/fuzz_targets/differential.rs @@ -323,7 +323,6 @@ impl DifferentialTarget for Wasmtime { } } -#[allow(dead_code)] // Note: dead code analysis somehow ignores Debug impl usage. #[derive(Debug, Default)] pub struct UnmatchedState { globals: Vec,