From 7c83be24082095ea9e4c2872ce21709b70523a16 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Fri, 21 Feb 2025 13:31:31 +0100 Subject: [PATCH] Add auto format to settings.json.default, format documentation and macros (#3019) * Add auto format to settings.json.default * Add more nightly rustfmt features --- .vscode/settings.json.default | 7 ++++ fuzzers/binary_only/qemu_cmin/src/fuzzer.rs | 1 - .../binary_only/qemu_coverage/src/fuzzer.rs | 1 - .../qemu_baremetal/src/fuzzer_breakpoint.rs | 1 - .../qemu_baremetal/src/fuzzer_low_level.rs | 1 - .../qemu_baremetal/src/fuzzer_sync_exit.rs | 1 - .../full_system/qemu_linux_kernel/src/main.rs | 1 - .../qemu_linux_process/src/main.rs | 1 - libafl/src/common/nautilus/mod.rs | 1 - libafl/src/events/llmp/mod.rs | 1 - libafl/src/executors/command.rs | 20 ++++++++---- libafl/src/executors/differential.rs | 1 - libafl/src/feedbacks/differential.rs | 1 - libafl/src/feedbacks/mod.rs | 3 +- libafl/src/feedbacks/value_bloom.rs | 1 - libafl/src/inputs/bytessub.rs | 2 +- libafl/src/inputs/nautilus.rs | 2 -- libafl/src/mutators/encoded_mutations.rs | 1 - libafl/src/mutators/mutations.rs | 2 +- libafl/src/observers/map/mod.rs | 12 +++++-- libafl/src/stages/concolic.rs | 1 - libafl/src/stages/push/mod.rs | 1 - libafl_bolts/src/cli.rs | 2 +- libafl_bolts/src/core_affinity.rs | 17 +++++----- libafl_bolts/src/lib.rs | 4 +-- libafl_bolts/src/os/mod.rs | 1 - libafl_bolts/src/os/unix_signals.rs | 3 +- libafl_bolts/src/rands/mod.rs | 4 +-- libafl_bolts/src/tuples.rs | 7 ++-- libafl_concolic/symcc_runtime/src/lib.rs | 4 +-- libafl_frida/src/helper.rs | 4 +-- libafl_frida/src/pthread_hook.rs | 32 +++++++++++-------- libafl_intelpt/src/linux.rs | 6 ++-- libafl_libfuzzer/src/lib.rs | 1 - libafl_qemu/src/qemu/hooks.rs | 4 +-- libafl_sugar/src/qemu.rs | 1 - libafl_targets/src/cmps/observers/cmplog.rs | 1 - rustfmt.toml | 4 +++ 38 files changed, 87 insertions(+), 71 deletions(-) diff --git a/.vscode/settings.json.default b/.vscode/settings.json.default index 59ac7c1a66..72a776738b 100644 --- a/.vscode/settings.json.default +++ b/.vscode/settings.json.default @@ -1,4 +1,11 @@ { + "[rust]": { + "editor.defaultFormatter": "rust-lang.rust-analyzer", + "editor.formatOnSave": true + }, + "rust-analyzer.rustfmt.extraArgs": [ + "+nightly" + ], "rust-analyzer.cargo.buildScripts.overrideCommand": [ "cargo", "check", diff --git a/fuzzers/binary_only/qemu_cmin/src/fuzzer.rs b/fuzzers/binary_only/qemu_cmin/src/fuzzer.rs index f9c63b5087..9cd8b328ce 100644 --- a/fuzzers/binary_only/qemu_cmin/src/fuzzer.rs +++ b/fuzzers/binary_only/qemu_cmin/src/fuzzer.rs @@ -1,5 +1,4 @@ //! A libfuzzer-like fuzzer using qemu for binary-only coverage -//! #[cfg(feature = "i386")] use core::mem::size_of; #[cfg(feature = "snapshot")] diff --git a/fuzzers/binary_only/qemu_coverage/src/fuzzer.rs b/fuzzers/binary_only/qemu_coverage/src/fuzzer.rs index a7171fd343..a84bcad6ec 100644 --- a/fuzzers/binary_only/qemu_coverage/src/fuzzer.rs +++ b/fuzzers/binary_only/qemu_coverage/src/fuzzer.rs @@ -1,5 +1,4 @@ //! A libfuzzer-like fuzzer using qemu for binary-only coverage -//! #[cfg(feature = "i386")] use core::mem::size_of; use core::time::Duration; diff --git a/fuzzers/full_system/qemu_baremetal/src/fuzzer_breakpoint.rs b/fuzzers/full_system/qemu_baremetal/src/fuzzer_breakpoint.rs index 5aff233c64..e3de64500e 100644 --- a/fuzzers/full_system/qemu_baremetal/src/fuzzer_breakpoint.rs +++ b/fuzzers/full_system/qemu_baremetal/src/fuzzer_breakpoint.rs @@ -1,5 +1,4 @@ //! A fuzzer using qemu in systemmode for binary-only coverage of kernels -//! use core::time::Duration; use std::{env, path::PathBuf, process}; diff --git a/fuzzers/full_system/qemu_baremetal/src/fuzzer_low_level.rs b/fuzzers/full_system/qemu_baremetal/src/fuzzer_low_level.rs index 837d0644c6..9aecb9c9c0 100644 --- a/fuzzers/full_system/qemu_baremetal/src/fuzzer_low_level.rs +++ b/fuzzers/full_system/qemu_baremetal/src/fuzzer_low_level.rs @@ -1,5 +1,4 @@ //! A fuzzer using qemu in systemmode for binary-only coverage of kernels -//! use core::time::Duration; use std::{env, path::PathBuf, process}; diff --git a/fuzzers/full_system/qemu_baremetal/src/fuzzer_sync_exit.rs b/fuzzers/full_system/qemu_baremetal/src/fuzzer_sync_exit.rs index 79e033fabb..6d490d1f5f 100644 --- a/fuzzers/full_system/qemu_baremetal/src/fuzzer_sync_exit.rs +++ b/fuzzers/full_system/qemu_baremetal/src/fuzzer_sync_exit.rs @@ -1,5 +1,4 @@ //! A fuzzer using qemu in systemmode for binary-only coverage of kernels -//! use core::time::Duration; use std::{env, path::PathBuf, process}; diff --git a/fuzzers/full_system/qemu_linux_kernel/src/main.rs b/fuzzers/full_system/qemu_linux_kernel/src/main.rs index fd6ca0acac..acd172dc8e 100644 --- a/fuzzers/full_system/qemu_linux_kernel/src/main.rs +++ b/fuzzers/full_system/qemu_linux_kernel/src/main.rs @@ -1,5 +1,4 @@ //! A systemmode linux kernel example -//! #[cfg(target_os = "linux")] mod fuzzer; diff --git a/fuzzers/full_system/qemu_linux_process/src/main.rs b/fuzzers/full_system/qemu_linux_process/src/main.rs index fd6ca0acac..acd172dc8e 100644 --- a/fuzzers/full_system/qemu_linux_process/src/main.rs +++ b/fuzzers/full_system/qemu_linux_process/src/main.rs @@ -1,5 +1,4 @@ //! A systemmode linux kernel example -//! #[cfg(target_os = "linux")] mod fuzzer; diff --git a/libafl/src/common/nautilus/mod.rs b/libafl/src/common/nautilus/mod.rs index 15b1ab2276..215c00cb6f 100644 --- a/libafl/src/common/nautilus/mod.rs +++ b/libafl/src/common/nautilus/mod.rs @@ -1,5 +1,4 @@ //! LibAFL version of the [`Nautilus`](https://github.com/nautilus-fuzz/nautilus) grammar fuzzer -//! #![doc = include_str!("README.md")] #[allow(missing_docs)] diff --git a/libafl/src/events/llmp/mod.rs b/libafl/src/events/llmp/mod.rs index 8e9d714cae..c2baf963d5 100644 --- a/libafl/src/events/llmp/mod.rs +++ b/libafl/src/events/llmp/mod.rs @@ -33,7 +33,6 @@ pub(crate) const _LLMP_TAG_EVENT_TO_CLIENT: Tag = Tag(0x2C11E471); /// Only handle this in the broker pub(crate) const _LLMP_TAG_EVENT_TO_BROKER: Tag = Tag(0x2B80438); /// Handle in both -/// pub(crate) const LLMP_TAG_EVENT_TO_BOTH: Tag = Tag(0x2B0741); pub(crate) const _LLMP_TAG_RESTART: Tag = Tag(0x8357A87); pub(crate) const _LLMP_TAG_NO_RESTART: Tag = Tag(0x57A7EE71); diff --git a/libafl/src/executors/command.rs b/libafl/src/executors/command.rs index 4e60cafebe..af2a1de78e 100644 --- a/libafl/src/executors/command.rs +++ b/libafl/src/executors/command.rs @@ -739,17 +739,25 @@ impl CommandExecutorBuilder { /// A `CommandConfigurator` takes care of creating and spawning a [`Command`] for the [`CommandExecutor`]. /// # Example /// ``` -/// use std::{io::Write, process::{Stdio, Command, Child}, time::Duration}; -/// use libafl::{Error, corpus::Corpus, inputs::{BytesInput, HasTargetBytes, Input}, executors::{Executor, command::CommandConfigurator}, state::{HasExecutions}}; +/// use std::{ +/// io::Write, +/// process::{Child, Command, Stdio}, +/// time::Duration, +/// }; +/// +/// use libafl::{ +/// corpus::Corpus, +/// executors::{command::CommandConfigurator, Executor}, +/// inputs::{BytesInput, HasTargetBytes, Input}, +/// state::HasExecutions, +/// Error, +/// }; /// use libafl_bolts::AsSlice; /// #[derive(Debug)] /// struct MyExecutor; /// /// impl CommandConfigurator for MyExecutor { -/// fn spawn_child( -/// &mut self, -/// input: &BytesInput, -/// ) -> Result { +/// fn spawn_child(&mut self, input: &BytesInput) -> Result { /// let mut command = Command::new("../if"); /// command /// .stdin(Stdio::piped()) diff --git a/libafl/src/executors/differential.rs b/libafl/src/executors/differential.rs index 12f4a13f8d..f9406d6b9e 100644 --- a/libafl/src/executors/differential.rs +++ b/libafl/src/executors/differential.rs @@ -2,7 +2,6 @@ //! //! It wraps two executors that will be run after each other with the same input. //! In comparison to the [`crate::executors::CombinedExecutor`] it also runs the secondary executor in `run_target`. -//! use core::{ cell::UnsafeCell, fmt::Debug, diff --git a/libafl/src/feedbacks/differential.rs b/libafl/src/feedbacks/differential.rs index e274fa1f92..90db0cdb07 100644 --- a/libafl/src/feedbacks/differential.rs +++ b/libafl/src/feedbacks/differential.rs @@ -1,5 +1,4 @@ //! Diff Feedback, comparing the content of two observers of the same type. -//! use alloc::borrow::Cow; use core::fmt::{self, Debug, Formatter}; diff --git a/libafl/src/feedbacks/mod.rs b/libafl/src/feedbacks/mod.rs index 2ec219f421..9402f18f60 100644 --- a/libafl/src/feedbacks/mod.rs +++ b/libafl/src/feedbacks/mod.rs @@ -1,6 +1,5 @@ //! The feedbacks reduce observer state after each run to a single `is_interesting`-value. //! If a testcase is interesting, it may be added to a Corpus. -//! // TODO: make S of Feedback an associated type when specialisation + AT is stable @@ -760,7 +759,7 @@ macro_rules! feedback_or_fast { /// Variadic macro to create a [`NotFeedback`] #[macro_export] macro_rules! feedback_not { - ( $last:expr ) => { + ($last:expr) => { $crate::feedbacks::NotFeedback::new($last) }; } diff --git a/libafl/src/feedbacks/value_bloom.rs b/libafl/src/feedbacks/value_bloom.rs index afa7e0646e..7f70112284 100644 --- a/libafl/src/feedbacks/value_bloom.rs +++ b/libafl/src/feedbacks/value_bloom.rs @@ -1,5 +1,4 @@ //! The [`ValueBloomFeedback`] checks if a value has already been observed in a [`BloomFilter`] and returns `true` if the value is new, adding it to the bloom filter. -//! use alloc::borrow::Cow; use core::hash::Hash; diff --git a/libafl/src/inputs/bytessub.rs b/libafl/src/inputs/bytessub.rs index c7ff4d1a54..fb4a97bc02 100644 --- a/libafl/src/inputs/bytessub.rs +++ b/libafl/src/inputs/bytessub.rs @@ -27,7 +27,7 @@ use crate::inputs::{HasMutatorBytes, ResizableMutator}; /// # #[no_mangle] /// # pub extern "C" fn external_current_millis() -> u64 { 0 } /// -/// let mut bytes_input = BytesInput::new(vec![1,2,3]); +/// let mut bytes_input = BytesInput::new(vec![1, 2, 3]); /// let mut sub_input = bytes_input.sub_input(1..); /// /// // Run any mutations on the sub input. diff --git a/libafl/src/inputs/nautilus.rs b/libafl/src/inputs/nautilus.rs index e088296429..17965b9123 100644 --- a/libafl/src/inputs/nautilus.rs +++ b/libafl/src/inputs/nautilus.rs @@ -1,6 +1,4 @@ //! Input for the [`Nautilus`](https://github.com/RUB-SysSec/nautilus) grammar fuzzer methods -//! -//! use alloc::{rc::Rc, vec::Vec}; use core::cell::RefCell; use std::hash::{Hash, Hasher}; diff --git a/libafl/src/mutators/encoded_mutations.rs b/libafl/src/mutators/encoded_mutations.rs index fe6e556f74..b3410f01bc 100644 --- a/libafl/src/mutators/encoded_mutations.rs +++ b/libafl/src/mutators/encoded_mutations.rs @@ -1,5 +1,4 @@ //! Mutations for [`EncodedInput`]s -//! use alloc::{borrow::Cow, vec::Vec}; use core::{ cmp::{max, min}, diff --git a/libafl/src/mutators/mutations.rs b/libafl/src/mutators/mutations.rs index df407839d9..8d60225b35 100644 --- a/libafl/src/mutators/mutations.rs +++ b/libafl/src/mutators/mutations.rs @@ -403,7 +403,7 @@ add_mutator_impl!(QwordAddMutator, u64); /////////////////////////// macro_rules! interesting_mutator_impl { - ($name: ident, $size: ty, $interesting: ident) => { + ($name:ident, $size:ty, $interesting:ident) => { /// Inserts an interesting value at a random place in the input vector #[derive(Default, Debug)] pub struct $name; diff --git a/libafl/src/observers/map/mod.rs b/libafl/src/observers/map/mod.rs index 5e76f9bb3b..7fe70b0d4b 100644 --- a/libafl/src/observers/map/mod.rs +++ b/libafl/src/observers/map/mod.rs @@ -219,7 +219,11 @@ pub mod macros { /// # phantom: PhantomData<(C, O)>, /// # } /// # - /// impl MyCustomScheduler where O: MapObserver, C: CanTrack + AsRef { + /// impl MyCustomScheduler + /// where + /// O: MapObserver, + /// C: CanTrack + AsRef, + /// { /// pub fn new(obs: &C) -> Self { /// require_index_tracking!("MyCustomScheduler", C); /// todo!("Construct your type") @@ -282,7 +286,11 @@ pub mod macros { /// # phantom: PhantomData<(C, O)>, /// # } /// # - /// impl MyCustomScheduler where O: MapObserver, C: CanTrack + AsRef { + /// impl MyCustomScheduler + /// where + /// O: MapObserver, + /// C: CanTrack + AsRef, + /// { /// pub fn new(obs: &C) -> Self { /// require_novelties_tracking!("MyCustomScheduler", C); /// todo!("Construct your type") diff --git a/libafl/src/stages/concolic.rs b/libafl/src/stages/concolic.rs index a1175c7173..aabd5cb835 100644 --- a/libafl/src/stages/concolic.rs +++ b/libafl/src/stages/concolic.rs @@ -1,6 +1,5 @@ //! This module contains the `concolic` stages, which can trace a target using symbolic execution //! and use the results for fuzzer input and mutations. -//! use alloc::borrow::{Cow, ToOwned}; #[cfg(feature = "concolic_mutation")] use alloc::{string::ToString, vec::Vec}; diff --git a/libafl/src/stages/push/mod.rs b/libafl/src/stages/push/mod.rs index bc17b55ded..c1b51881ec 100644 --- a/libafl/src/stages/push/mod.rs +++ b/libafl/src/stages/push/mod.rs @@ -4,7 +4,6 @@ //! A push stage instead returns an iterator that generates a new result for each time it gets called. //! With the new testcase, you will have to take care about testcase execution, manually. //! The push stage relies on internal mutability of the supplied `Observers`. -//! /// Mutational stage is the normal fuzzing stage. pub mod mutational; diff --git a/libafl_bolts/src/cli.rs b/libafl_bolts/src/cli.rs index 8c9486ffe6..92b4360423 100644 --- a/libafl_bolts/src/cli.rs +++ b/libafl_bolts/src/cli.rs @@ -59,7 +59,7 @@ //! //! log::info!("{:?}", parsed); //! } -//!``` +//! ``` #[cfg(feature = "frida_cli")] use alloc::{boxed::Box, string::ToString}; diff --git a/libafl_bolts/src/core_affinity.rs b/libafl_bolts/src/core_affinity.rs index 4408065c7c..e9dca26af1 100644 --- a/libafl_bolts/src/core_affinity.rs +++ b/libafl_bolts/src/core_affinity.rs @@ -14,19 +14,21 @@ //! //! // Create a thread for each active CPU core. //! # #[cfg(not(miri))] -//! let handles = core_ids.into_iter().map(|id| { -//! thread::spawn(move || { -//! // Pin this thread to a single CPU core. -//! id.set_affinity(); -//! // Do more work after this. +//! let handles = core_ids +//! .into_iter() +//! .map(|id| { +//! thread::spawn(move || { +//! // Pin this thread to a single CPU core. +//! id.set_affinity(); +//! // Do more work after this. +//! }) //! }) -//! }).collect::>(); +//! .collect::>(); //! //! # #[cfg(not(miri))] //! for handle in handles.into_iter() { //! handle.join().unwrap(); //! } -//! //! ``` //! //! *This file is a fork of * @@ -60,7 +62,6 @@ impl CoreId { /// Note: This will *_not_* fail if the target platform does not support core affinity. /// (only on error cases for supported platforms) /// If you really need to fail for unsupported platforms (like `aarch64` on `macOS`), use [`CoreId::set_affinity_forced`] instead. - /// pub fn set_affinity(&self) -> Result<(), Error> { match set_for_current_helper(*self) { Ok(()) | Err(Error::Unsupported(_, _)) => Ok(()), diff --git a/libafl_bolts/src/lib.rs b/libafl_bolts/src/lib.rs index 95e539cf07..6207d65f1e 100644 --- a/libafl_bolts/src/lib.rs +++ b/libafl_bolts/src/lib.rs @@ -1,6 +1,6 @@ /*! -* Welcome to `LibAFL_bolts` -*/ + * Welcome to `LibAFL_bolts` + */ #![doc = include_str!("../README.md")] /*! */ #![cfg_attr(feature = "document-features", doc = document_features::document_features!())] diff --git a/libafl_bolts/src/os/mod.rs b/libafl_bolts/src/os/mod.rs index 655d79e234..a90c6fc4d7 100644 --- a/libafl_bolts/src/os/mod.rs +++ b/libafl_bolts/src/os/mod.rs @@ -1,5 +1,4 @@ //! Operating System specific abstractions -//! #[cfg(any(unix, all(windows, feature = "std")))] use crate::Error; diff --git a/libafl_bolts/src/os/unix_signals.rs b/libafl_bolts/src/os/unix_signals.rs index 76c3efa6d5..8ff6a11775 100644 --- a/libafl_bolts/src/os/unix_signals.rs +++ b/libafl_bolts/src/os/unix_signals.rs @@ -173,7 +173,7 @@ pub struct arm_neon_state64 { /// _STRUCT_ARM_EXCEPTION_STATE64 es; /// _STRUCT_ARM_THREAD_STATE64 ss; /// _STRUCT_ARM_NEON_STATE64 ns; -///}; +/// }; /// ``` #[cfg(all(target_vendor = "apple", target_arch = "aarch64"))] #[derive(Debug)] @@ -271,7 +271,6 @@ use crate::Error; extern "C" { /// The `libc` `getcontext` /// For some reason, it's not available on `MacOS`. - /// fn getcontext(ucp: *mut ucontext_t) -> c_int; } diff --git a/libafl_bolts/src/rands/mod.rs b/libafl_bolts/src/rands/mod.rs index 5c72e2c5ab..b7d8177cf4 100644 --- a/libafl_bolts/src/rands/mod.rs +++ b/libafl_bolts/src/rands/mod.rs @@ -223,7 +223,7 @@ pub trait Rand: Debug + Serialize + DeserializeOwned { } macro_rules! impl_default_new { - ($rand: ty) => { + ($rand:ty) => { impl Default for $rand { /// Creates a generator seeded with [`random_seed`]. fn default() -> Self { @@ -249,7 +249,7 @@ impl_default_new!(RomuDuoJrRand); impl_default_new!(Sfc64Rand); macro_rules! impl_rng_core { - ($rand: ty) => { + ($rand:ty) => { #[cfg(feature = "rand_trait")] impl rand_core::RngCore for $rand { fn next_u32(&mut self) -> u32 { diff --git a/libafl_bolts/src/tuples.rs b/libafl_bolts/src/tuples.rs index a8ff63a925..21f4647342 100644 --- a/libafl_bolts/src/tuples.rs +++ b/libafl_bolts/src/tuples.rs @@ -809,7 +809,7 @@ macro_rules! tuple_for_each_mut { /// ```rust /// use libafl_bolts::{ /// map_tuple_list_type, -/// tuples::{MappingFunctor, Map, tuple_list, tuple_list_type} +/// tuples::{tuple_list, tuple_list_type, Map, MappingFunctor}, /// }; /// /// struct Wrapper(T); @@ -842,7 +842,10 @@ macro_rules! map_tuple_list_type { /// Merges the types of two merged [`tuple_list!`]s /// /// ```rust -/// use libafl_bolts::{merge_tuple_list_type, tuples::{Merge, tuple_list, tuple_list_type}}; +/// use libafl_bolts::{ +/// merge_tuple_list_type, +/// tuples::{tuple_list, tuple_list_type, Merge}, +/// }; /// /// struct A; /// struct B; diff --git a/libafl_concolic/symcc_runtime/src/lib.rs b/libafl_concolic/symcc_runtime/src/lib.rs index f0e3fd35bd..08cbf523b0 100644 --- a/libafl_concolic/symcc_runtime/src/lib.rs +++ b/libafl_concolic/symcc_runtime/src/lib.rs @@ -124,10 +124,10 @@ macro_rules! make_symexpr_optional { #[doc(hidden)] #[macro_export] macro_rules! unwrap_option { - ($param_name:ident: RSymExpr) => { + ($param_name:ident : RSymExpr) => { $param_name? }; - ($param_name:ident: $($type:tt)+) => { + ($param_name:ident : $($type:tt)+) => { $param_name }; } diff --git a/libafl_frida/src/helper.rs b/libafl_frida/src/helper.rs index 33781059c6..3e7a9fe0ac 100644 --- a/libafl_frida/src/helper.rs +++ b/libafl_frida/src/helper.rs @@ -347,7 +347,7 @@ impl FridaInstrumentationHelperBuilder { /// # Example /// Instrument all modules in `/usr/lib` as well as `libfoo.so`: /// ``` - ///# use libafl_frida::helper::FridaInstrumentationHelper; + /// # use libafl_frida::helper::FridaInstrumentationHelper; /// let builder = FridaInstrumentationHelper::builder() /// .instrument_module_if(|module| module.name() == "libfoo.so") /// .instrument_module_if(|module| module.path().starts_with("/usr/lib")); @@ -376,7 +376,7 @@ impl FridaInstrumentationHelperBuilder { /// Instrument all modules in `/usr/lib`, but exclude `libfoo.so`. /// /// ``` - ///# use libafl_frida::helper::FridaInstrumentationHelper; + /// # use libafl_frida::helper::FridaInstrumentationHelper; /// let builder = FridaInstrumentationHelper::builder() /// .instrument_module_if(|module| module.path().starts_with("/usr/lib")) /// .skip_module_if(|module| module.name() == "libfoo.so"); diff --git a/libafl_frida/src/pthread_hook.rs b/libafl_frida/src/pthread_hook.rs index f6c83d8b7d..f986ab71a0 100644 --- a/libafl_frida/src/pthread_hook.rs +++ b/libafl_frida/src/pthread_hook.rs @@ -131,18 +131,24 @@ impl From for libc::c_uint { /// Set a `pthread_introspection` hook. /// # Example /// ``` -///# use libafl_frida::pthread_hook; -///# use std::time::Duration; -///# use std::thread; +/// # use libafl_frida::pthread_hook; +/// # use std::time::Duration; +/// # use std::thread; /// unsafe { -/// pthread_hook::install(|event, pthread, addr, size| { -/// log::trace!("thread id=0x{:x} event={:?} addr={:?} size={:x}", pthread, event, addr, size); -/// }); +/// pthread_hook::install(|event, pthread, addr, size| { +/// log::trace!( +/// "thread id=0x{:x} event={:?} addr={:?} size={:x}", +/// pthread, +/// event, +/// addr, +/// size +/// ); +/// }); /// }; -///# thread::spawn(|| { -///# thread::sleep(Duration::from_millis(1)); -///# }); -///# thread::sleep(Duration::from_millis(50)); +/// # thread::spawn(|| { +/// # thread::sleep(Duration::from_millis(1)); +/// # }); +/// # thread::sleep(Duration::from_millis(50)); /// ``` /// This should output the thread IDs, lifecycle events, addresses and sizes of the corresponding events. /// ```no_test @@ -174,9 +180,9 @@ where /// Restore a previously set `pthread_introspection` hook. /// # Example /// ``` -///# use libafl_frida::pthread_hook; -///# use std::time::Duration; -///# use std::thread; +/// # use libafl_frida::pthread_hook; +/// # use std::time::Duration; +/// # use std::thread; /// unsafe { pthread_hook::reset() }; /// ``` /// diff --git a/libafl_intelpt/src/linux.rs b/libafl_intelpt/src/linux.rs index 5dd823e90d..aaffcbcfa7 100644 --- a/libafl_intelpt/src/linux.rs +++ b/libafl_intelpt/src/linux.rs @@ -538,8 +538,10 @@ impl Default for IntelPTBuilder { /// .exclude_kernel(true) /// .exclude_hv(true) /// .inherit(false) - /// .perf_buffer_size(128 * PAGE_SIZE + PAGE_SIZE).unwrap() - /// .perf_aux_buffer_size(2 * 1024 * 1024).unwrap() + /// .perf_buffer_size(128 * PAGE_SIZE + PAGE_SIZE) + /// .unwrap() + /// .perf_aux_buffer_size(2 * 1024 * 1024) + /// .unwrap() /// .ip_filters(&[]); /// assert_eq!(builder, IntelPTBuilder::default()); /// ``` diff --git a/libafl_libfuzzer/src/lib.rs b/libafl_libfuzzer/src/lib.rs index 057c831c86..1703d980d5 100644 --- a/libafl_libfuzzer/src/lib.rs +++ b/libafl_libfuzzer/src/lib.rs @@ -73,7 +73,6 @@ //! This crate links to a (separately built) internal crate which affords the actual functionality. //! The internal crate must be built separately to ensure flags from dependent crates are not leaked //! to the runtime (e.g., to prevent coverage being collected on the runtime). -//! #![cfg_attr(feature = "document-features", doc = document_features::document_features!())] #![cfg_attr(not(test), warn( missing_debug_implementations, diff --git a/libafl_qemu/src/qemu/hooks.rs b/libafl_qemu/src/qemu/hooks.rs index e8c14201d0..f2422e15c5 100644 --- a/libafl_qemu/src/qemu/hooks.rs +++ b/libafl_qemu/src/qemu/hooks.rs @@ -380,7 +380,7 @@ macro_rules! create_exec_wrapper { } macro_rules! create_hook_id { - ($name:ident, $sys:ident, true) => { + ($name:ident, $sys:ident,true) => { paste::paste! { #[derive(Clone, Copy, PartialEq, Debug)] pub struct [<$name HookId>](pub(crate) usize); @@ -397,7 +397,7 @@ macro_rules! create_hook_id { } } }; - ($name:ident, $sys:ident, false) => { + ($name:ident, $sys:ident,false) => { paste::paste! { #[derive(Clone, Copy, PartialEq, Debug)] pub struct [<$name HookId>](pub(crate) usize); diff --git a/libafl_sugar/src/qemu.rs b/libafl_sugar/src/qemu.rs index 50c8d3a284..199acc58b5 100644 --- a/libafl_sugar/src/qemu.rs +++ b/libafl_sugar/src/qemu.rs @@ -1,5 +1,4 @@ //! In-memory fuzzer with `QEMU`-based binary-only instrumentation -//! use core::fmt::{self, Debug, Formatter}; use std::{fs, net::SocketAddr, path::PathBuf, time::Duration}; diff --git a/libafl_targets/src/cmps/observers/cmplog.rs b/libafl_targets/src/cmps/observers/cmplog.rs index 3b90edcbdd..eeb15d7782 100644 --- a/libafl_targets/src/cmps/observers/cmplog.rs +++ b/libafl_targets/src/cmps/observers/cmplog.rs @@ -1,6 +1,5 @@ //! `CmpLog` logs and reports back values touched during fuzzing. //! The values will then be used in subsequent mutations. -//! use alloc::borrow::Cow; use core::fmt::Debug; diff --git a/rustfmt.toml b/rustfmt.toml index 44b6aab556..e8a7e54654 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1,6 @@ group_imports = "StdExternalCrate" imports_granularity = "Crate" +newline_style = "Unix" +format_code_in_doc_comments = true +format_macro_bodies = true +format_macro_matchers = true