Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix clippy lints #78

Merged
merged 5 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ pub fn driver() -> io::Result<bool> {
.collect();

/* convert to runner env variable */
let host = host.replace('-', "_").replace('.', "_").to_uppercase();
let runner = format!("CARGO_TARGET_{}_RUNNER", host);
let host = host.replace(['-', '.'], "_").to_uppercase();
let runner = format!("CARGO_TARGET_{host}_RUNNER");

/* cargo run with a custom runner */
let cargo_valgrind = env::args_os()
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn display_error(errors: &[valgrind::xml::Error]) {
fn main() {
panic::replace_hook();

let number_of_arguments = || env::args_os().skip(0).count();
let number_of_arguments = || env::args_os().skip(1).count();
jfrimmel marked this conversation as resolved.
Show resolved Hide resolved
let help_requested = || env::args_os().any(|arg| arg == "--help" || arg == "-h");
let is_cargo_subcommand = || env::args_os().nth(1).map_or(false, |arg| arg == "valgrind");
if number_of_arguments() == 0 || help_requested() {
Expand All @@ -79,7 +79,7 @@ fn main() {
textwrap::Options::with_termwidth(),
)
.join("\n");
println!("{}", text);
println!("{text}");
} else if is_cargo_subcommand() {
if !driver::driver().expect("Could not execute subcommand") {
process::exit(200);
Expand Down
8 changes: 3 additions & 5 deletions src/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//! addition information is printed (e.g. for [`Error::MalformedOutput`]).
//!
//! [`Error::MalformedOutput`]: crate::valgrind::Error::MalformedOutput
#![allow(clippy::module_name_repetitions)]

use crate::valgrind::Error;
use std::panic;
Expand Down Expand Up @@ -53,7 +54,7 @@ pub fn replace_hook() {
textwrap::Options::with_termwidth(),
)
.join("\n");
eprintln!("{}", text);
eprintln!("{text}");

eprintln!(
"{}: version {}",
Expand All @@ -64,10 +65,7 @@ pub fn replace_hook() {
// intentionally not wrapped using `textwrap`, since own formatting
// might be applied.
if let Some(Error::MalformedOutput(e, content)) = panic.payload().downcast_ref() {
eprintln!(
"XML format mismatch between `valgrind` and `cargo valgrind`: {}",
e
);
eprintln!("XML format mismatch between `valgrind` and `cargo valgrind`: {e}");
eprintln!(
"XML output of valgrind:\n```xml\n{}```",
String::from_utf8_lossy(content)
Expand Down
6 changes: 3 additions & 3 deletions src/valgrind/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ impl fmt::Display for Error {
Self::ValgrindNotInstalled => write!(f, "valgrind executable not found"),
Self::SocketConnection => write!(f, "local TCP I/O error"),
Self::ProcessFailed => write!(f, "cannot start valgrind process"),
Self::ValgrindFailure(s) => write!(f, "invalid valgrind usage: {}", s),
Self::MalformedOutput(e, _) => write!(f, "unexpected valgrind output: {}", e),
Self::ValgrindFailure(s) => write!(f, "invalid valgrind usage: {s}"),
Self::MalformedOutput(e, _) => write!(f, "unexpected valgrind output: {e}"),
}
}
}
Expand All @@ -60,7 +60,7 @@ where

// additional options to pass to valgrind?
if let Ok(additional_args) = env::var("VALGRINDFLAGS") {
valgrind.args(additional_args.split(" "));
valgrind.args(additional_args.split(' '));
}

let cargo = valgrind
Expand Down
4 changes: 2 additions & 2 deletions src/valgrind/xml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl Display for Frame {
f.write_str(" (")?;
f.write_str(file)?;
if let Some(line) = self.line {
write!(f, ":{}", line)?;
write!(f, ":{line}")?;
}
f.write_str(")")?;
}
Expand All @@ -168,6 +168,6 @@ impl<'de> Visitor<'de> for HexVisitor {
.strip_prefix("0x")
.ok_or_else(|| E::custom("'0x' prefix missing"))?;
Self::Value::from_str_radix(value, 16)
.map_err(|_| E::custom(format!("invalid hex number '{}'", value)))
.map_err(|_| E::custom(format!("invalid hex number '{value}'")))
}
}
2 changes: 1 addition & 1 deletion tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn leak_detected() {
#[test]
fn examples_are_runnable() {
cargo_valgrind()
.args(&["run", "--example", "no-leak"])
.args(["run", "--example", "no-leak"])
.args(TARGET_CRATE)
.assert()
.success()
Expand Down
Loading