Skip to content

Commit 78d4d36

Browse files
committed
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.
1 parent 305384a commit 78d4d36

File tree

3 files changed

+16
-20
lines changed
  • contrib/devtools
    • deterministic-fuzz-coverage/src
    • deterministic-unittest-coverage/src
  • test/lint/test_runner/src

3 files changed

+16
-20
lines changed

contrib/devtools/deterministic-fuzz-coverage/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn sanity_check(corpora_dir: &Path, fuzz_exe: &Path) -> AppResult {
3636
let output = Command::new(tool).arg("--help").output();
3737
match output {
3838
Ok(output) if output.status.success() => {}
39-
_ => Err(exit_help(&format!("The tool {} is not installed", tool)))?,
39+
_ => Err(exit_help(&format!("The tool {tool} is not installed")))?,
4040
}
4141
}
4242
if !corpora_dir.is_dir() {
@@ -274,7 +274,7 @@ fn main() -> ExitCode {
274274
match app() {
275275
Ok(()) => ExitCode::SUCCESS,
276276
Err(err) => {
277-
eprintln!("⚠️\n{}", err);
277+
eprintln!("⚠️\n{err}");
278278
ExitCode::FAILURE
279279
}
280280
}

contrib/devtools/deterministic-unittest-coverage/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn sanity_check(test_exe: &Path) -> AppResult {
3232
let output = Command::new(tool).arg("--help").output();
3333
match output {
3434
Ok(output) if output.status.success() => {}
35-
_ => Err(exit_help(&format!("The tool {} is not installed", tool)))?,
35+
_ => Err(exit_help(&format!("The tool {tool} is not installed")))?,
3636
}
3737
}
3838
if !test_exe.exists() {
@@ -142,7 +142,7 @@ fn main() -> ExitCode {
142142
match app() {
143143
Ok(()) => ExitCode::SUCCESS,
144144
Err(err) => {
145-
eprintln!("⚠️\n{}", err);
145+
eprintln!("⚠️\n{err}");
146146
ExitCode::FAILURE
147147
}
148148
}

test/lint/test_runner/src/main.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ fn get_pathspecs_default_excludes() -> Vec<String> {
223223
.chain(&[
224224
"doc/release-notes/release-notes-*", // archived notes
225225
])
226-
.map(|s| format!(":(exclude){}", s))
226+
.map(|s| format!(":(exclude){s}"))
227227
.collect()
228228
}
229229

@@ -280,8 +280,7 @@ fn lint_commit_msg() -> LintResult {
280280
if let Some(line) = commit_info.lines().nth(1) {
281281
if !line.is_empty() {
282282
println!(
283-
"The subject line of commit hash {} is followed by a non-empty line. Subject lines should always be followed by a blank line.",
284-
hash
283+
"The subject line of commit hash {hash} is followed by a non-empty line. Subject lines should always be followed by a blank line."
285284
);
286285
good = false;
287286
}
@@ -351,15 +350,14 @@ fn lint_py_lint() -> LintResult {
351350

352351
match cmd.status() {
353352
Ok(status) if status.success() => Ok(()),
354-
Ok(_) => Err(format!("`{}` found errors!", bin_name)),
353+
Ok(_) => Err(format!("`{bin_name}` found errors!")),
355354
Err(e) if e.kind() == ErrorKind::NotFound => {
356355
println!(
357-
"`{}` was not found in $PATH, skipping those checks.",
358-
bin_name
356+
"`{bin_name}` was not found in $PATH, skipping those checks."
359357
);
360358
Ok(())
361359
}
362-
Err(e) => Err(format!("Error running `{}`: {}", bin_name, e)),
360+
Err(e) => Err(format!("Error running `{bin_name}`: {e}")),
363361
}
364362
}
365363

@@ -491,7 +489,7 @@ fn get_pathspecs_exclude_whitespace() -> Vec<String> {
491489
"test/lint/git-subtree-check.sh",
492490
]
493491
.iter()
494-
.map(|s| format!(":(exclude){}", s)),
492+
.map(|s| format!(":(exclude){s}")),
495493
);
496494
list
497495
}
@@ -650,14 +648,13 @@ still succeed, but silently be buggy. For example, a slower fallback algorithm c
650648
even though bitcoin-build-config.h indicates that a faster feature is available and should be used.
651649
652650
If you are unsure which symbol is used, you can find it with this command:
653-
git grep --perl-regexp '{}' -- file_name
651+
git grep --perl-regexp '{defines_regex}' -- file_name
654652
655653
Make sure to include it with the IWYU pragma. Otherwise, IWYU may falsely instruct to remove the
656654
include again.
657655
658656
#include <bitcoin-build-config.h> // IWYU pragma: keep
659-
"#,
660-
defines_regex
657+
"#
661658
)
662659
.trim()
663660
.to_string());
@@ -714,9 +711,8 @@ One or more markdown links are broken.
714711
Note: relative links are preferred as jump-to-file works natively within Emacs, but they are not required.
715712
716713
Markdown link errors found:
717-
{}
718-
"#,
719-
stderr
714+
{stderr}
715+
"#
720716
)
721717
.trim()
722718
.to_string())
@@ -725,7 +721,7 @@ Markdown link errors found:
725721
println!("`mlc` was not found in $PATH, skipping markdown lint check.");
726722
Ok(())
727723
}
728-
Err(e) => Err(format!("Error running mlc: {}", e)), // Misc errors
724+
Err(e) => Err(format!("Error running mlc: {e}")), // Misc errors
729725
}
730726
}
731727

@@ -744,7 +740,7 @@ fn run_all_python_linters() -> LintResult {
744740
.success()
745741
{
746742
good = false;
747-
println!("^---- ⚠️ Failure generated from {}", entry_fn);
743+
println!("^---- ⚠️ Failure generated from {entry_fn}");
748744
}
749745
}
750746
if good {

0 commit comments

Comments
 (0)