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 all commits
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
2 changes: 1 addition & 1 deletion .clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.51.0"
msrv = "1.58.1"
2 changes: 1 addition & 1 deletion .github/workflows/msrv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
env:
CARGO_TERM_COLOR: always
MSRV: "1.51"
MSRV: "1.58.1"
jobs:
# Build and test the tool with the Minimum Supported Rust Version
msrv:
Expand Down
4 changes: 2 additions & 2 deletions src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ pub fn driver() -> io::Result<bool> {
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "could not determine host"))?;

/* 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
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn display_stack_trace(msg: &str, stack: &valgrind::xml::Stack) {
stack
.frames
.iter()
.for_each(|frame| eprintln!(" at {}", frame));
.for_each(|frame| eprintln!(" at {frame}"));
}

fn main() {
Expand Down Expand Up @@ -119,7 +119,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 All @@ -146,11 +146,11 @@ fn main() {
{
let error = "Error".red().bold();
let info = "Info".cyan().bold();
eprintln!("{:>12}: looks like the program overflowed its stack", error);
eprintln!("{:>12}: valgrind says:", info);
eprintln!("{error:>12}: looks like the program overflowed its stack");
eprintln!("{info:>12}: valgrind says:");
output
.lines()
.for_each(|line| eprintln!(" {}", line));
.for_each(|line| eprintln!(" {line}"));
134 // default exit code for stack overflows
}
Err(e) => {
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 @@ -54,7 +55,7 @@ pub fn replace_hook() {
textwrap::Options::with_termwidth(),
)
.join("\n");
eprintln!("{}", text);
eprintln!("{text}");

eprintln!(
"{}: version {}",
Expand All @@ -65,10 +66,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
4 changes: 2 additions & 2 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 Down
4 changes: 2 additions & 2 deletions src/valgrind/xml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,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 @@ -196,6 +196,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