Skip to content

Commit 5fb2d63

Browse files
committed
Fix uninlined_format_args in libtest
1 parent 224fa39 commit 5fb2d63

File tree

7 files changed

+15
-24
lines changed

7 files changed

+15
-24
lines changed

Diff for: library/test/src/cli.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,7 @@ fn get_shuffle_seed(matches: &getopts::Matches, allow_unstable: bool) -> OptPart
354354
Err(e) => {
355355
return Err(format!(
356356
"argument for --shuffle-seed must be a number \
357-
(error: {})",
358-
e
357+
(error: {e})"
359358
));
360359
}
361360
},
@@ -383,8 +382,7 @@ fn get_test_threads(matches: &getopts::Matches) -> OptPartRes<Option<usize>> {
383382
Err(e) => {
384383
return Err(format!(
385384
"argument for --test-threads must be a number > 0 \
386-
(error: {})",
387-
e
385+
(error: {e})"
388386
));
389387
}
390388
},
@@ -418,8 +416,7 @@ fn get_format(
418416
Some(v) => {
419417
return Err(format!(
420418
"argument for --format must be pretty, terse, json or junit (was \
421-
{})",
422-
v
419+
{v})"
423420
));
424421
}
425422
};
@@ -436,8 +433,7 @@ fn get_color_config(matches: &getopts::Matches) -> OptPartRes<ColorConfig> {
436433
Some(v) => {
437434
return Err(format!(
438435
"argument for --color must be auto, always, or never (was \
439-
{})",
440-
v
436+
{v})"
441437
));
442438
}
443439
};

Diff for: library/test/src/formatters/json.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<T: Write> JsonFormatter<T> {
5353
self.write_message(&*format!(r#", "stdout": "{}""#, EscapedString(stdout)))?;
5454
}
5555
if let Some(extra) = extra {
56-
self.write_message(&*format!(r#", {}"#, extra))?;
56+
self.write_message(&*format!(r#", {extra}"#))?;
5757
}
5858
self.writeln_message(" }")
5959
}
@@ -62,13 +62,12 @@ impl<T: Write> JsonFormatter<T> {
6262
impl<T: Write> OutputFormatter for JsonFormatter<T> {
6363
fn write_run_start(&mut self, test_count: usize, shuffle_seed: Option<u64>) -> io::Result<()> {
6464
let shuffle_seed_json = if let Some(shuffle_seed) = shuffle_seed {
65-
format!(r#", "shuffle_seed": {}"#, shuffle_seed)
65+
format!(r#", "shuffle_seed": {shuffle_seed}"#)
6666
} else {
6767
String::new()
6868
};
6969
self.writeln_message(&*format!(
70-
r#"{{ "type": "suite", "event": "started", "test_count": {}{} }}"#,
71-
test_count, shuffle_seed_json
70+
r#"{{ "type": "suite", "event": "started", "test_count": {test_count}{shuffle_seed_json} }}"#
7271
))
7372
}
7473

Diff for: library/test/src/formatters/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ pub(crate) fn write_stderr_delimiter(test_output: &mut Vec<u8>, test_name: &Test
3838
Some(_) => test_output.push(b'\n'),
3939
None => (),
4040
}
41-
writeln!(test_output, "---- {} stderr ----", test_name).unwrap();
41+
writeln!(test_output, "---- {test_name} stderr ----").unwrap();
4242
}

Diff for: library/test/src/formatters/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<T: Write> PrettyFormatter<T> {
4747

4848
pub fn write_ignored(&mut self, message: Option<&'static str>) -> io::Result<()> {
4949
if let Some(message) = message {
50-
self.write_short_result(&format!("ignored, {}", message), term::color::YELLOW)
50+
self.write_short_result(&format!("ignored, {message}"), term::color::YELLOW)
5151
} else {
5252
self.write_short_result("ignored", term::color::YELLOW)
5353
}

Diff for: library/test/src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ pub fn assert_test_result<T: Termination>(result: T) -> Result<(), String> {
213213
} else {
214214
Err(format!(
215215
"the test returned a termination value with a non-zero status code \
216-
({}) which indicates a failure",
217-
code
216+
({code}) which indicates a failure"
218217
))
219218
}
220219
}
@@ -750,7 +749,7 @@ fn spawn_test_subprocess(
750749
})() {
751750
Ok(r) => r,
752751
Err(e) => {
753-
write!(&mut test_output, "Unexpected error: {}", e).unwrap();
752+
write!(&mut test_output, "Unexpected error: {e}").unwrap();
754753
TrFailed
755754
}
756755
};

Diff for: library/test/src/test_result.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ pub fn calc_result<'a>(
4444
} else if let Some(panic_str) = maybe_panic_str {
4545
TestResult::TrFailedMsg(format!(
4646
r#"panic did not contain expected string
47-
panic message: `{:?}`,
48-
expected substring: `{:?}`"#,
49-
panic_str, msg
47+
panic message: `{panic_str:?}`,
48+
expected substring: `{msg:?}`"#
5049
))
5150
} else {
5251
TestResult::TrFailedMsg(format!(

Diff for: library/test/src/time.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,14 @@ impl TimeThreshold {
107107
let durations_str = env::var(env_var_name).ok()?;
108108
let (warn_str, critical_str) = durations_str.split_once(',').unwrap_or_else(|| {
109109
panic!(
110-
"Duration variable {} expected to have 2 numbers separated by comma, but got {}",
111-
env_var_name, durations_str
110+
"Duration variable {env_var_name} expected to have 2 numbers separated by comma, but got {durations_str}"
112111
)
113112
});
114113

115114
let parse_u64 = |v| {
116115
u64::from_str(v).unwrap_or_else(|_| {
117116
panic!(
118-
"Duration value in variable {} is expected to be a number, but got {}",
119-
env_var_name, v
117+
"Duration value in variable {env_var_name} is expected to be a number, but got {v}"
120118
)
121119
})
122120
};

0 commit comments

Comments
 (0)