Skip to content

Commit

Permalink
Remove unused code and some unused annotations (#1077)
Browse files Browse the repository at this point in the history
* remove unused code

* remove unused warnings allowances

* add comment to warning allowance
  • Loading branch information
Robbepop authored Jun 18, 2024
1 parent 82d96f3 commit f8fd9d1
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 33 deletions.
3 changes: 0 additions & 3 deletions crates/wasmi/src/engine/executor/stack/calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 0 additions & 20 deletions crates/wasmi/src/engine/executor/stack/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`]
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 0 additions & 5 deletions crates/wasmi/src/engine/executor/stack/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion crates/wasmi/src/engine/translator/tests/op/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<i32> {
<Const16<i32>>::try_from(value)
.unwrap_or_else(|_| panic!("value must be 16-bit encodable: {}", value))
Expand Down
2 changes: 0 additions & 2 deletions crates/wasmi/src/func/into_func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ mod tests {
marker: core::marker::PhantomData<fn() -> 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;
}
Expand All @@ -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.
Expand Down
1 change: 0 additions & 1 deletion crates/wasmi/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 0 additions & 1 deletion fuzz/fuzz_targets/differential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<UnmatchedGlobal>,
Expand Down

0 comments on commit f8fd9d1

Please sign in to comment.