Skip to content

Commit 0750a6c

Browse files
authored
refactor: Remove unnecessary Debug trait bounds (#1667)
* refactor: Remove Debug supertraits Instead of having the Debug trait as supertrait on several traits, the Debug trait is now required in bounds in specific implementations that need this specific trait. This keeps the API cleaner, since users now don't have to propagate the Debug requirement if they don't need to use the Debug trait. * refactor: Reformat code
1 parent b1888e1 commit 0750a6c

File tree

18 files changed

+48
-49
lines changed

18 files changed

+48
-49
lines changed

libafl/src/executors/command.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ where
215215

216216
impl<OT, S> CommandExecutor<OT, S, StdCommandConfigurator>
217217
where
218-
OT: MatchName + Debug + ObserversTuple<S>,
218+
OT: MatchName + ObserversTuple<S>,
219219
S: UsesInput,
220220
{
221221
/// Creates a new `CommandExecutor`.
@@ -315,7 +315,7 @@ where
315315
EM: UsesState<State = S>,
316316
S: UsesInput + HasExecutions,
317317
S::Input: HasTargetBytes,
318-
T: CommandConfigurator + Debug,
318+
T: CommandConfigurator,
319319
OT: Debug + MatchName + ObserversTuple<S>,
320320
Z: UsesState<State = S>,
321321
{
@@ -565,7 +565,7 @@ impl CommandExecutorBuilder {
565565
observers: OT,
566566
) -> Result<CommandExecutor<OT, S, StdCommandConfigurator>, Error>
567567
where
568-
OT: Debug + MatchName + ObserversTuple<S>,
568+
OT: MatchName + ObserversTuple<S>,
569569
S: UsesInput,
570570
{
571571
let Some(program) = &self.program else {
@@ -660,7 +660,7 @@ impl CommandExecutorBuilder {
660660
/// ```
661661
662662
#[cfg(all(feature = "std", any(unix, doc)))]
663-
pub trait CommandConfigurator: Sized + Debug {
663+
pub trait CommandConfigurator: Sized {
664664
/// Spawns a new process with the given configuration.
665665
fn spawn_child<I>(&mut self, input: &I) -> Result<Child, Error>
666666
where
@@ -672,7 +672,7 @@ pub trait CommandConfigurator: Sized + Debug {
672672
/// Create an `Executor` from this `CommandConfigurator`.
673673
fn into_executor<OT, S>(self, observers: OT) -> CommandExecutor<OT, S, Self>
674674
where
675-
OT: Debug + MatchName,
675+
OT: MatchName,
676676
{
677677
CommandExecutor {
678678
observers,

libafl/src/executors/forkserver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ impl<E> TimeoutForkserverExecutor<E> {
522522

523523
impl<E, EM, Z> Executor<EM, Z> for TimeoutForkserverExecutor<E>
524524
where
525-
E: Executor<EM, Z> + HasForkserver + HasObservers + Debug,
525+
E: Executor<EM, Z> + HasForkserver + HasObservers,
526526
E::Input: HasTargetBytes,
527527
E::State: HasExecutions,
528528
EM: UsesState<State = E::State>,

libafl/src/executors/inprocess.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<H, HB, OT, S> Debug for GenericInProcessExecutor<H, HB, OT, S>
9090
where
9191
H: FnMut(&S::Input) -> ExitKind + ?Sized,
9292
HB: BorrowMut<H>,
93-
OT: ObserversTuple<S>,
93+
OT: ObserversTuple<S> + Debug,
9494
S: UsesInput,
9595
{
9696
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
@@ -1599,7 +1599,7 @@ where
15991599
impl<'a, H, OT, S, SP> Debug for InProcessForkExecutor<'a, H, OT, S, SP>
16001600
where
16011601
H: FnMut(&S::Input) -> ExitKind + ?Sized,
1602-
OT: ObserversTuple<S>,
1602+
OT: ObserversTuple<S> + Debug,
16031603
S: UsesInput,
16041604
SP: ShMemProvider,
16051605
{
@@ -1615,7 +1615,7 @@ where
16151615
impl<'a, H, OT, S, SP> Debug for TimeoutInProcessForkExecutor<'a, H, OT, S, SP>
16161616
where
16171617
H: FnMut(&S::Input) -> ExitKind + ?Sized,
1618-
OT: ObserversTuple<S>,
1618+
OT: ObserversTuple<S> + Debug,
16191619
S: UsesInput,
16201620
SP: ShMemProvider,
16211621
{

libafl/src/executors/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub trait HasObservers: UsesObservers {
118118
}
119119

120120
/// An executor takes the given inputs, and runs the harness/target.
121-
pub trait Executor<EM, Z>: UsesState + Debug
121+
pub trait Executor<EM, Z>: UsesState
122122
where
123123
EM: UsesState<State = Self::State>,
124124
Z: UsesState<State = Self::State>,
@@ -166,7 +166,7 @@ where
166166
impl<EM, S, Z> Executor<EM, Z> for NopExecutor<S>
167167
where
168168
EM: UsesState<State = S>,
169-
S: UsesInput + Debug + HasExecutions,
169+
S: UsesInput + HasExecutions,
170170
S::Input: HasTargetBytes,
171171
Z: UsesState<State = S>,
172172
{

libafl/src/executors/shadow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ where
3232

3333
impl<E, SOT> ShadowExecutor<E, SOT>
3434
where
35-
E: HasObservers + Debug,
36-
SOT: ObserversTuple<E::State> + Debug,
35+
E: HasObservers,
36+
SOT: ObserversTuple<E::State>,
3737
{
3838
/// Create a new `ShadowExecutor`, wrapping the given `executor`.
3939
pub fn new(executor: E, shadow_observers: SOT) -> Self {

libafl/src/executors/with_observers.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ pub struct WithObservers<E, OT> {
1818

1919
impl<E, EM, OT, Z> Executor<EM, Z> for WithObservers<E, OT>
2020
where
21-
E: Executor<EM, Z> + Debug,
22-
OT: Debug,
21+
E: Executor<EM, Z>,
2322
EM: UsesState<State = E::State>,
2423
Z: UsesState<State = E::State>,
2524
{
@@ -53,8 +52,8 @@ where
5352

5453
impl<E, OT> HasObservers for WithObservers<E, OT>
5554
where
56-
E: UsesState + Debug,
57-
OT: ObserversTuple<E::State> + Debug,
55+
E: UsesState,
56+
OT: ObserversTuple<E::State>,
5857
{
5958
fn observers(&self) -> &OT {
6059
&self.observers
@@ -65,7 +64,7 @@ where
6564
}
6665
}
6766

68-
impl<E: Debug, OT: Debug> WithObservers<E, OT> {
67+
impl<E, OT> WithObservers<E, OT> {
6968
/// Wraps the given [`Executor`] with the given [`ObserversTuple`] to implement [`HasObservers`].
7069
///
7170
/// If the executor already implements [`HasObservers`], then the original implementation will be overshadowed by

libafl/src/feedbacks/concolic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<S> Named for ConcolicFeedback<S> {
4949

5050
impl<S> Feedback<S> for ConcolicFeedback<S>
5151
where
52-
S: UsesInput + Debug + HasClientPerfMonitor,
52+
S: UsesInput + HasClientPerfMonitor,
5353
{
5454
#[allow(clippy::wrong_self_convention)]
5555
fn is_interesting<EM, OT>(

libafl/src/feedbacks/map.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub type MaxMapPow2Feedback<O, S, T> = MapFeedback<NextPow2IsNovel, O, MaxReduce
5050
pub type MaxMapOneOrFilledFeedback<O, S, T> = MapFeedback<OneOrFilledIsNovel, O, MaxReducer, S, T>;
5151

5252
/// A `Reducer` function is used to aggregate values for the novelty search
53-
pub trait Reducer<T>: 'static + Debug
53+
pub trait Reducer<T>: 'static
5454
where
5555
T: Default + Copy + 'static,
5656
{
@@ -137,7 +137,7 @@ where
137137
}
138138

139139
/// A `IsNovel` function is used to discriminate if a reduced value is considered novel.
140-
pub trait IsNovel<T>: 'static + Debug
140+
pub trait IsNovel<T>: 'static
141141
where
142142
T: Default + Copy + 'static,
143143
{
@@ -392,10 +392,10 @@ where
392392

393393
impl<N, O, R, S, T> Feedback<S> for MapFeedback<N, O, R, S, T>
394394
where
395-
N: IsNovel<T> + Debug,
395+
N: IsNovel<T>,
396396
O: MapObserver<Entry = T> + for<'it> AsIter<'it, Item = T>,
397-
R: Reducer<T> + Debug,
398-
S: UsesInput + HasClientPerfMonitor + HasNamedMetadata + Debug,
397+
R: Reducer<T>,
398+
S: UsesInput + HasClientPerfMonitor + HasNamedMetadata,
399399
T: Default + Copy + Serialize + for<'de> Deserialize<'de> + PartialEq + Debug + 'static,
400400
{
401401
fn init_state(&mut self, state: &mut S) -> Result<(), Error> {
@@ -496,7 +496,7 @@ impl<O, S> Feedback<S> for MapFeedback<DifferentIsNovel, O, MaxReducer, S, u8>
496496
where
497497
O: MapObserver<Entry = u8> + AsSlice<Entry = u8>,
498498
for<'it> O: AsIter<'it, Item = u8>,
499-
S: UsesInput + HasNamedMetadata + HasClientPerfMonitor + Debug,
499+
S: UsesInput + HasNamedMetadata + HasClientPerfMonitor,
500500
{
501501
#[allow(clippy::wrong_self_convention)]
502502
#[allow(clippy::needless_range_loop)]
@@ -664,7 +664,7 @@ where
664664
O: MapObserver<Entry = T>,
665665
for<'it> O: AsIter<'it, Item = T>,
666666
N: IsNovel<T>,
667-
S: UsesInput + HasNamedMetadata + HasClientPerfMonitor + Debug,
667+
S: UsesInput + HasNamedMetadata + HasClientPerfMonitor,
668668
{
669669
/// Create new `MapFeedback`
670670
#[must_use]
@@ -875,7 +875,7 @@ where
875875

876876
impl<O, S> Feedback<S> for ReachabilityFeedback<O, S>
877877
where
878-
S: UsesInput + Debug + HasClientPerfMonitor,
878+
S: UsesInput + HasClientPerfMonitor,
879879
O: MapObserver<Entry = usize>,
880880
for<'it> O: AsIter<'it, Item = usize>,
881881
{

libafl/src/feedbacks/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use crate::{
4747
/// Feedbacks evaluate the observers.
4848
/// Basically, they reduce the information provided by an observer to a value,
4949
/// indicating the "interestingness" of the last run.
50-
pub trait Feedback<S>: Named + Debug
50+
pub trait Feedback<S>: Named
5151
where
5252
S: UsesInput + HasClientPerfMonitor,
5353
{
@@ -186,7 +186,7 @@ where
186186
A: Feedback<S>,
187187
B: Feedback<S>,
188188
FL: FeedbackLogic<A, B, S>,
189-
S: UsesInput + HasClientPerfMonitor + Debug,
189+
S: UsesInput + HasClientPerfMonitor,
190190
{
191191
fn init_state(&mut self, state: &mut S) -> Result<(), Error> {
192192
self.first.init_state(state)?;
@@ -265,7 +265,7 @@ where
265265
}
266266

267267
/// Logical combination of two feedbacks
268-
pub trait FeedbackLogic<A, B, S>: 'static + Debug
268+
pub trait FeedbackLogic<A, B, S>: 'static
269269
where
270270
A: Feedback<S>,
271271
B: Feedback<S>,
@@ -619,7 +619,7 @@ where
619619

620620
impl<A, S> Debug for NotFeedback<A, S>
621621
where
622-
A: Feedback<S>,
622+
A: Feedback<S> + Debug,
623623
S: UsesInput + HasClientPerfMonitor,
624624
{
625625
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {

libafl/src/feedbacks/new_hash_feedback.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ pub struct NewHashFeedback<O, S> {
8787

8888
impl<O, S> Feedback<S> for NewHashFeedback<O, S>
8989
where
90-
O: ObserverWithHashField + Named + Debug,
91-
S: UsesInput + Debug + HasNamedMetadata + HasClientPerfMonitor,
90+
O: ObserverWithHashField + Named,
91+
S: UsesInput + HasNamedMetadata + HasClientPerfMonitor,
9292
{
9393
fn init_state(&mut self, state: &mut S) -> Result<(), Error> {
9494
state.add_named_metadata(
@@ -157,7 +157,7 @@ const DEFAULT_CAPACITY: usize = 4096;
157157

158158
impl<O, S> NewHashFeedback<O, S>
159159
where
160-
O: ObserverWithHashField + Named + Debug,
160+
O: ObserverWithHashField + Named,
161161
{
162162
/// Returns a new [`NewHashFeedback`].
163163
/// Setting an observer name that doesn't exist would eventually trigger a panic.

0 commit comments

Comments
 (0)