Skip to content

Commit

Permalink
Fix some warnings on nightly (bytecodealliance#1409)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton authored Feb 9, 2024
1 parent d514f70 commit f43b418
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 51 deletions.
16 changes: 0 additions & 16 deletions crates/wasm-mutate/src/mutators/codemotion/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,22 +185,6 @@ pub trait AstWriter {
Ok(())
}

/// Default encoding for code node
///
/// This function is called by the defaut implementation
/// of the `write_code` method
fn write_code_default<'a>(
&self,
ast: &Ast,
nodeidx: usize,
range: Range<usize>,
newfunc: &mut Function,
operators: &Vec<OperatorAndByteOffset>,
input_wasm: &'a [u8],
) -> crate::Result<()> {
self.write_code(ast, nodeidx, range, newfunc, operators, input_wasm)
}

/// Encoding discriminator for the Ast nodes
///
/// It calls the corresponding methods depending on the node type
Expand Down
36 changes: 1 addition & 35 deletions crates/wasm-mutate/src/mutators/peephole.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ use crate::{
Error, ErrorKind, ModuleInfo, Result, WasmMutate,
};
use egg::{Rewrite, Runner};
use rand::{prelude::SmallRng, Rng};
use std::ops::Range;
use std::{borrow::Cow, fmt::Debug};
use rand::Rng;
use wasm_encoder::{CodeSection, ConstExpr, Function, GlobalSection, Module, ValType};
use wasmparser::{CodeSectionReader, FunctionBody, GlobalSectionReader, LocalsReader};

Expand Down Expand Up @@ -447,38 +445,6 @@ impl Mutator for PeepholeMutator {
}
}

impl Debug for Box<dyn CodeMutator> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_tuple("Code mutator").finish()
}
}

pub(crate) trait CodeMutator {
fn mutate(
&self,
config: &WasmMutate,
rnd: &mut SmallRng,
operator_index: usize,
operators: Vec<OperatorAndByteOffset>,
funcreader: FunctionBody,
body_range: Range<usize>,
function_data: &[u8],
) -> Result<Function>;

/// Returns if this mutator can be applied to the opcode at index i
fn can_mutate<'a>(
&self,
config: &'a WasmMutate,
operators: &[OperatorAndByteOffset<'a>],
at: usize,
) -> Result<bool>;

/// Provides the name of the mutator, mostly used for debugging purposes
fn name(&self) -> Cow<'static, str> {
std::any::type_name::<Self>().into()
}
}

// This macro is meant to be used for testing deep mutators
// It receives the original wat text variable, the expression returning the mutated function and the expected wat
// For an example, look at SwapCommutativeOperator
Expand Down

0 comments on commit f43b418

Please sign in to comment.