diff --git a/src/corpus/mod.rs b/src/corpus/mod.rs index 3a4517bced..e6db9fb483 100644 --- a/src/corpus/mod.rs +++ b/src/corpus/mod.rs @@ -102,7 +102,7 @@ where } } -impl Corpus for InMemoryCorpus< I, R> +impl Corpus for InMemoryCorpus where I: Input, R: Rand, diff --git a/src/engines/mod.rs b/src/engines/mod.rs index c9ff590356..19ce6b7fac 100644 --- a/src/engines/mod.rs +++ b/src/engines/mod.rs @@ -196,10 +196,10 @@ mod tests { let mut corpus = InMemoryCorpus::::new(&rand); let mut executor = InMemoryExecutor::new(harness); let mut engine = DefaultEngine::new(&mut corpus, &mut executor); - let mut stage = Box::new(DefaultMutationalStage::new(&rand, &mut engine)); + let stage = Box::new(DefaultMutationalStage::new(&rand, &mut engine)); engine.add_stage(stage); engine.fuzz_one().unwrap(); - let mut stage1 = Box::new(DefaultMutationalStage::new(&rand, &mut engine)); + let stage1 = Box::new(DefaultMutationalStage::new(&rand, &mut engine)); engine.fuzz_one().unwrap(); } } diff --git a/src/mutators/scheduled.rs b/src/mutators/scheduled.rs index 8939d059fa..0c14a1c127 100644 --- a/src/mutators/scheduled.rs +++ b/src/mutators/scheduled.rs @@ -4,9 +4,9 @@ use crate::mutators::{HasOptionCorpus, Mutator}; use crate::utils::{HasRand, Rand}; use crate::AflError; +use std::cell::RefCell; use std::marker::PhantomData; use std::rc::Rc; -use std::cell::RefCell; /// The generic function type that identifies mutations type MutationFunction = fn(&mut M, &mut I) -> Result<(), AflError>; diff --git a/src/stages/mutational.rs b/src/stages/mutational.rs index d26aea9b41..8bd263f525 100644 --- a/src/stages/mutational.rs +++ b/src/stages/mutational.rs @@ -70,7 +70,6 @@ where fn rand(&self) -> &Rc> { &self.rand } - } impl<'a, I, R, E> HasEvaluator for DefaultMutationalStage<'a, I, R, E> diff --git a/src/utils.rs b/src/utils.rs index 258ff64662..fbfdea27a8 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,9 +1,9 @@ //! Utility functions for AFL -use std::debug_assert; -use std::rc::Rc; use std::cell::RefCell; +use std::debug_assert; use std::fmt::Debug; +use std::rc::Rc; use xxhash_rust::xxh3::xxh3_64_with_seed; /// Ways to get random around here @@ -59,7 +59,9 @@ pub trait HasRand { // Gets a value between the given lower bound (inclusive) and upper bound (inclusive) fn rand_between(&self, lower_bound_incl: u64, upper_bound_incl: u64) -> u64 { - self.rand().borrow_mut().between(lower_bound_incl, upper_bound_incl) + self.rand() + .borrow_mut() + .between(lower_bound_incl, upper_bound_incl) } } @@ -128,7 +130,7 @@ pub fn next_pow2(val: u64) -> u64 { #[cfg(test)] mod tests { - use crate::utils::{next_pow2, Rand, HasRand, Xoshiro256StarRand}; + use crate::utils::{next_pow2, HasRand, Rand, Xoshiro256StarRand}; #[test] fn test_rand() { @@ -140,18 +142,18 @@ mod tests { assert!(rand.between(11, 20) > 10); } - use std::rc::Rc; use std::cell::RefCell; + use std::rc::Rc; struct HasRandTest where R: Rand, { - rand: Rc> + rand: Rc>, } impl HasRand for HasRandTest where - R: Rand + R: Rand, { type R = R; @@ -162,11 +164,12 @@ mod tests { fn test_has_rand() { let rand = Xoshiro256StarRand::new_rc(); - let has_rand = HasRandTest{rand: Rc::clone(&rand)}; + let has_rand = HasRandTest { + rand: Rc::clone(&rand), + }; assert!(has_rand.rand_below(100) < 100); assert_eq!(has_rand.rand_below(1), 0); - } #[test]