Skip to content

Commit

Permalink
handle clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekleog committed Jan 28, 2023
1 parent fe75abd commit 154db5e
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 31 deletions.
4 changes: 2 additions & 2 deletions bolero-engine/src/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl Display for Backtrace {
for (i, frame) in self.frames.iter().enumerate() {
writeln!(f, " {}: {}", i, frame.symbol)?;
if let Some(location) = frame.location.as_ref() {
writeln!(f, " at {}", location)?;
writeln!(f, " at {location}")?;
}
}

Expand All @@ -223,7 +223,7 @@ impl BacktraceFrame {
symbol: name,
location: symbol.filename().map(|filename| {
if let Some(lineno) = symbol.lineno() {
format!("{}:{}", filename.display(), lineno)
format!("{}:{lineno}", filename.display())
} else {
filename.display().to_string()
}
Expand Down
4 changes: 2 additions & 2 deletions bolero-engine/src/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ where
)
.expect("test should fail");

eprintln!("{}", failure);
eprintln!("{failure}");

std::panic::resume_unwind(Box::new(failure));
}
#[cfg(miri)]
Err(failure) => {
// don't shrink in Miri execution
eprintln!("{}", failure);
eprintln!("{failure}");
std::panic::resume_unwind(Box::new(failure));
}
}
Expand Down
3 changes: 1 addition & 2 deletions bolero-engine/src/shrink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ impl<'a, T: Test> Shrinker<'a, T> {
{
if self.execute().is_ok() {
eprintln!(
"transform created non-failing test: {}\nBEFORE: {:?}\nAFTER: {:?}",
transform,
"transform created non-failing test: {transform}\nBEFORE: {:?}\nAFTER: {:?}",
&self.snapshot_input,
&self.input[..self.end],
);
Expand Down
4 changes: 2 additions & 2 deletions bolero-engine/src/test_failure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ impl<Input: Debug> Display for TestFailure<Input> {
"\n======================== Test Failure ========================\n"
)?;
if let Some(seed) = &self.seed {
writeln!(f, "BOLERO_RANDOM_SEED={}\n", seed)?;
writeln!(f, "BOLERO_RANDOM_SEED={seed}\n")?;
}
writeln!(f, "Input: \n{:#?}\n", self.input)?;
writeln!(f, "Error: \n{}", self.error)?;

if f.alternate() {
if let Some(backtrace) = self.error.backtrace.as_ref().filter(|_| rust_backtrace()) {
writeln!(f, "{}", backtrace)?;
writeln!(f, "{backtrace}")?;
} else {
writeln!(f, "note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.")?;
}
Expand Down
4 changes: 2 additions & 2 deletions bolero-generator-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ fn generate_fields_unnamed_type_mutate(
fields: &FieldsUnnamed,
) -> TokenStream2 {
let fields = fields.unnamed.iter().enumerate().map(|(index, field)| {
let value = Ident::new(&format!("__bolero_unnamed_{}", index), field.span());
let value = Ident::new(&format!("__bolero_unnamed_{index}"), field.span());
let generator = GeneratorAttr::from_attrs(krate, field.attrs.iter());

let span = generator.span();
Expand All @@ -334,7 +334,7 @@ fn generate_fields_unnamed_type_destructure<C: ToTokens>(
.unnamed
.iter()
.enumerate()
.map(|(index, field)| Ident::new(&format!("__bolero_unnamed_{}", index), field.span()));
.map(|(index, field)| Ident::new(&format!("__bolero_unnamed_{index}"), field.span()));
quote!(#constructor (#(#fields),*))
}

Expand Down
14 changes: 7 additions & 7 deletions bolero-honggfuzz/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ fn build(target: &str, file: &str, lib: &str) -> String {
assert!(status.success());

std::fs::copy(
format!("honggfuzz/{}", target),
format!("{}/{}", out_dir, file),
format!("honggfuzz/{target}"),
format!("{out_dir}/{file}"),
)
.expect("could not copy target");

println!("cargo:rustc-link-lib=static={}", lib);
println!("cargo:rustc-link-search=native={}", &out_dir);
println!("cargo:rustc-link-lib=static={lib}");
println!("cargo:rustc-link-search=native={out_dir}");

std::fs::copy(
"honggfuzz/libhfcommon/libhfcommon.a",
format!("{}/libhfcommon.a", out_dir),
format!("{out_dir}/libhfcommon.a"),
)
.expect("could not copy libhfcommon.a");

Expand Down Expand Up @@ -82,7 +82,7 @@ fn main() {
]
.iter()
{
println!("cargo:rustc-link-lib=framework={}", framework);
println!("cargo:rustc-link-lib=framework={framework}");
}
}

Expand All @@ -96,7 +96,7 @@ fn main() {
]
.iter()
{
println!("cargo:rustc-link-lib={}", lib);
println!("cargo:rustc-link-lib={lib}");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion bolero-libfuzzer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub mod fuzzer {
test.shrink(slice.to_vec(), None, driver_mode, self.shrink_time);

if let Some(shrunken) = shrunken {
eprintln!("{:#}", shrunken);
eprintln!("{shrunken:#}");
} else {
eprintln!(
"{:#}",
Expand Down
8 changes: 4 additions & 4 deletions bolero/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl TestEngine {
Some(seed)
})
.map(move |seed| NamedTest {
name: format!("[BOLERO_RANDOM_SEED={}]", seed),
name: format!("[BOLERO_RANDOM_SEED={seed}]"),
data: TestInput::RngTest(RngTest {
seed,
max_len: rng_info.max_len,
Expand Down Expand Up @@ -137,7 +137,7 @@ where
test.shrink(buffer.clone(), data.seed(), driver_mode, shrink_time);

if let Some(shrunken) = shrunken {
format!("{:#}", shrunken)
format!("{shrunken:#}")
} else {
format!(
"{:#}",
Expand Down Expand Up @@ -165,7 +165,7 @@ where
);

if let Some(shrunken) = shrunken {
format!("{:#}", shrunken)
format!("{shrunken:#}")
} else {
buffer.clear();
let mut input = conf.input(&mut buffer);
Expand Down Expand Up @@ -194,7 +194,7 @@ where

if let Err(err) = testfn(&test.data) {
bolero_engine::panic::forward_panic(true);
eprintln!("{}", err);
eprintln!("{err}");
panic!("test failed: {:?}", test.name);
}
}
Expand Down
2 changes: 1 addition & 1 deletion cargo-bolero/src/afl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub(crate) fn test(selection: &Selection, test_args: &test::Args) -> Result<()>
if let Some(runs) = test_args.runs {
std::env::set_var("AFL_EXIT_WHEN_DONE", "1");
let cycles = runs / 100_000; // a cycle is about 100,000 runs
std::env::set_var("BOLERO_AFL_MAX_CYCLES", format!("{}", cycles));
std::env::set_var("BOLERO_AFL_MAX_CYCLES", format!("{cycles}"));
}

let mut args = vec![
Expand Down
2 changes: 1 addition & 1 deletion cargo-bolero/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl FromStr for Engine {
#[cfg(feature = "kani")]
"kani" => Ok(Self::Kani),

_ => Err(format!("invalid fuzzer {:?}", value)),
_ => Err(format!("invalid fuzzer {value:?}")),
}
}
}
2 changes: 1 addition & 1 deletion cargo-bolero/src/honggfuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ macro_rules! optional_arg {
($cmd:ident, $harg:expr, $arg:expr) => {
if let Some(value) = $arg {
$cmd.push($harg.to_string());
$cmd.push(format!("{}", value));
$cmd.push(format!("{value}"));
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion cargo-bolero/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl List {
// ignore the status in case any tests failed

for target in TestTarget::all_from_stdout(&output.stdout)? {
println!("{}", target);
println!("{target}");
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion cargo-bolero/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn main() {

if let Err(err) = Commands::from_iter(args).exec() {
// Formatting anyhow error with {:#} to print all the error causes.
eprintln!("error: {:#}", err);
eprintln!("error: {err:#}");
std::process::exit(1);
}
}
Expand Down
2 changes: 1 addition & 1 deletion cargo-bolero/src/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ fn mkdir<P: AsRef<Path>>(path: P) {
fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) {
let path = path.as_ref();
fs::write(path, contents).expect("could not create file");
println!("wrote {:?}", path);
println!("wrote {path:?}");
}
4 changes: 2 additions & 2 deletions cargo-bolero/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl Project {
.arg("-vV")
.output()
.with_context(|| {
format!("failed to determine {} toolchain version", toolchain)
format!("failed to determine {toolchain} toolchain version")
})?
.stdout;
let stdout = core::str::from_utf8(&stdout)?;
Expand Down Expand Up @@ -210,7 +210,7 @@ impl Project {

fn sanitizer_flags(&self) -> impl Iterator<Item = String> + '_ {
self.sanitizers()
.map(|sanitizer| format!("-Zsanitizer={}", sanitizer))
.map(|sanitizer| format!("-Zsanitizer={sanitizer}"))
}

fn release(&self) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion cargo-bolero/src/test_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl TestTarget {
1 => Ok(targets.pop().unwrap()),
_ => {
for target in targets {
eprintln!("{}", target);
eprintln!("{target}");
}
Err(anyhow!("multiple targets matched"))
}
Expand Down

0 comments on commit 154db5e

Please sign in to comment.