test: Format strings in *.rs

`format!` strings may contain variables within the string
representation. This is a lint as of a recent `rustc` nightly version.
This commit is contained in:
rustaceanrob committed 2025-10-31 13:39:54 +00:00
1 parent 305384a037
commit 78d4d36730
3 files changed
+16 -20

No files matched your search

@@ -36,7 +36,7 @@ fn sanity_check(corpora_dir: &Path, fuzz_exe: &Path) -> AppResult {
let output = Command::new(tool).arg("--help").output(); let output = Command::new(tool).arg("--help").output();
match output { match output {
Ok(output) if output.status.success() => {} Ok(output) if output.status.success() => {}
_ => Err(exit_help(&format!("The tool {} is not installed", tool)))?, _ => Err(exit_help(&format!("The tool {tool} is not installed")))?,
} }
} }
if !corpora_dir.is_dir() { if !corpora_dir.is_dir() {
@@ -274,7 +274,7 @@ fn main() -> ExitCode {
match app() { match app() {
Ok(()) => ExitCode::SUCCESS, Ok(()) => ExitCode::SUCCESS,
Err(err) => { Err(err) => {
eprintln!("⚠️\n{}", err); eprintln!("⚠️\n{err}");
ExitCode::FAILURE ExitCode::FAILURE
} }
} }
@@ -32,7 +32,7 @@ fn sanity_check(test_exe: &Path) -> AppResult {
let output = Command::new(tool).arg("--help").output(); let output = Command::new(tool).arg("--help").output();
match output { match output {
Ok(output) if output.status.success() => {} Ok(output) if output.status.success() => {}
_ => Err(exit_help(&format!("The tool {} is not installed", tool)))?, _ => Err(exit_help(&format!("The tool {tool} is not installed")))?,
} }
} }
if !test_exe.exists() { if !test_exe.exists() {
@@ -142,7 +142,7 @@ fn main() -> ExitCode {
match app() { match app() {
Ok(()) => ExitCode::SUCCESS, Ok(()) => ExitCode::SUCCESS,
Err(err) => { Err(err) => {
eprintln!("⚠️\n{}", err); eprintln!("⚠️\n{err}");
ExitCode::FAILURE ExitCode::FAILURE
} }
} }
+12 -16
View File
@@ -223,7 +223,7 @@ fn get_pathspecs_default_excludes() -> Vec<String> {
.chain(&[ .chain(&[
"doc/release-notes/release-notes-*", // archived notes "doc/release-notes/release-notes-*", // archived notes
]) ])
.map(|s| format!(":(exclude){}", s)) .map(|s| format!(":(exclude){s}"))
.collect() .collect()
} }
@@ -280,8 +280,7 @@ fn lint_commit_msg() -> LintResult {
if let Some(line) = commit_info.lines().nth(1) { if let Some(line) = commit_info.lines().nth(1) {
if !line.is_empty() { if !line.is_empty() {
println!( println!(
"The subject line of commit hash {} is followed by a non-empty line. Subject lines should always be followed by a blank line.", "The subject line of commit hash {hash} is followed by a non-empty line. Subject lines should always be followed by a blank line."
hash
); );
good = false; good = false;
} }
@@ -351,15 +350,14 @@ fn lint_py_lint() -> LintResult {
match cmd.status() { match cmd.status() {
Ok(status) if status.success() => Ok(()), Ok(status) if status.success() => Ok(()),
Ok(_) => Err(format!("`{}` found errors!", bin_name)), Ok(_) => Err(format!("`{bin_name}` found errors!")),
Err(e) if e.kind() == ErrorKind::NotFound => { Err(e) if e.kind() == ErrorKind::NotFound => {
println!( println!(
"`{}` was not found in $PATH, skipping those checks.", "`{bin_name}` was not found in $PATH, skipping those checks."
bin_name
); );
Ok(()) Ok(())
} }
Err(e) => Err(format!("Error running `{}`: {}", bin_name, e)), Err(e) => Err(format!("Error running `{bin_name}`: {e}")),
} }
} }
@@ -491,7 +489,7 @@ fn get_pathspecs_exclude_whitespace() -> Vec<String> {
"test/lint/git-subtree-check.sh", "test/lint/git-subtree-check.sh",
] ]
.iter() .iter()
.map(|s| format!(":(exclude){}", s)), .map(|s| format!(":(exclude){s}")),
); );
list list
} }
@@ -650,14 +648,13 @@ still succeed, but silently be buggy. For example, a slower fallback algorithm c
even though bitcoin-build-config.h indicates that a faster feature is available and should be used. even though bitcoin-build-config.h indicates that a faster feature is available and should be used.
If you are unsure which symbol is used, you can find it with this command: If you are unsure which symbol is used, you can find it with this command:
git grep --perl-regexp '{}' -- file_name git grep --perl-regexp '{defines_regex}' -- file_name
Make sure to include it with the IWYU pragma. Otherwise, IWYU may falsely instruct to remove the Make sure to include it with the IWYU pragma. Otherwise, IWYU may falsely instruct to remove the
include again. include again.
#include <bitcoin-build-config.h> // IWYU pragma: keep #include <bitcoin-build-config.h> // IWYU pragma: keep
"#, "#
defines_regex
) )
.trim() .trim()
.to_string()); .to_string());
@@ -714,9 +711,8 @@ One or more markdown links are broken.
Note: relative links are preferred as jump-to-file works natively within Emacs, but they are not required. Note: relative links are preferred as jump-to-file works natively within Emacs, but they are not required.
Markdown link errors found: Markdown link errors found:
{} {stderr}
"#, "#
stderr
) )
.trim() .trim()
.to_string()) .to_string())
@@ -725,7 +721,7 @@ Markdown link errors found:
println!("`mlc` was not found in $PATH, skipping markdown lint check."); println!("`mlc` was not found in $PATH, skipping markdown lint check.");
Ok(()) Ok(())
} }
Err(e) => Err(format!("Error running mlc: {}", e)), // Misc errors Err(e) => Err(format!("Error running mlc: {e}")), // Misc errors
} }
} }
@@ -744,7 +740,7 @@ fn run_all_python_linters() -> LintResult {
.success() .success()
{ {
good = false; good = false;
println!("^---- ⚠️ Failure generated from {}", entry_fn); println!("^---- ⚠️ Failure generated from {entry_fn}");
} }
} }
if good { if good {