Skip to content

Commit 601544f

Browse files
authored
Merge pull request #538 from nicholasbishop/bishop-fix-new-clippies
Fix clippy warnings
2 parents 78d110c + cd761ed commit 601544f

File tree

6 files changed

+24
-21
lines changed

6 files changed

+24
-21
lines changed

src/data_types/guid.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ impl Guid {
8989

9090
impl fmt::Display for Guid {
9191
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
92+
let a = self.a;
93+
let b = self.b;
94+
let c = self.c;
95+
9296
let d = {
9397
let mut buf = [0u8; 2];
9498
buf[..].copy_from_slice(&self.d[0..2]);
@@ -102,11 +106,7 @@ impl fmt::Display for Guid {
102106
u64::from_be_bytes(buf)
103107
};
104108

105-
write!(
106-
fmt,
107-
"{:08x}-{:04x}-{:04x}-{:04x}-{:012x}",
108-
self.a, self.b, self.c, d, e
109-
)
109+
write!(fmt, "{a:08x}-{b:04x}-{c:04x}-{d:04x}-{e:012x}",)
110110
}
111111
}
112112

src/logger.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,13 @@ impl<'writer, 'a, W: fmt::Write> fmt::Write for DecoratedLog<'writer, 'a, W> {
148148
)?;
149149
self.at_line_start = false;
150150
}
151-
write!(self.writer, "{}", first)?;
151+
write!(self.writer, "{first}")?;
152152

153153
// For the remainder of the line iterator (if any), we know that we are
154154
// truly at the beginning of lines of output.
155155
for line in lines {
156-
write!(self.writer, "\n{}: {}", self.log_level, line)?;
156+
let level = self.log_level;
157+
write!(self.writer, "\n{level}: {line}")?;
157158
}
158159

159160
// If the string ends with a newline character, we must 1/propagate it

src/table/revision.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ impl fmt::Debug for Revision {
5252
/// Formats the revision in the `major.minor.patch` format.
5353
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
5454
let (major, minor) = (self.major(), self.minor());
55-
write!(f, "{}.{}.{}", major, minor / 10, minor % 10)
55+
let minor = minor / 10;
56+
let patch = minor % 10;
57+
write!(f, "{major}.{minor}.{patch}")
5658
}
5759
}
5860

src/table/runtime.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,11 +519,11 @@ impl fmt::Display for Time {
519519
let fraction_part = offset_in_hours - (integer_part as f32);
520520
// most time zones
521521
if fraction_part == 0.0 {
522-
write!(f, "UTC+{}", offset_in_hours)?;
522+
write!(f, "UTC+{offset_in_hours}")?;
523523
}
524524
// time zones with 30min offset (and perhaps other special time zones)
525525
else {
526-
write!(f, "UTC+{:.1}", offset_in_hours)?;
526+
write!(f, "UTC+{offset_in_hours:.1}")?;
527527
}
528528
}
529529

@@ -636,8 +636,8 @@ impl fmt::Display for VariableKey {
636636
write!(f, "VariableKey {{ name: ")?;
637637

638638
match self.name() {
639-
Ok(name) => write!(f, "\"{}\"", name)?,
640-
Err(err) => write!(f, "Err({:?})", err)?,
639+
Ok(name) => write!(f, "\"{name}\"")?,
640+
Err(err) => write!(f, "Err({err:?})")?,
641641
}
642642

643643
write!(f, ", vendor: ")?;

xtask/src/pipe.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ impl Pipe {
1919
pub fn new(dir: &Path, base_name: &'static str) -> Result<Self> {
2020
if platform::is_unix() {
2121
let qemu_arg = format!("pipe:{}", dir.join(base_name).to_str().unwrap());
22-
let input_path = dir.join(format!("{}.in", base_name));
23-
let output_path = dir.join(format!("{}.out", base_name));
22+
let input_path = dir.join(format!("{base_name}.in"));
23+
let output_path = dir.join(format!("{base_name}.out"));
2424

2525
// This part has to be conditionally compiled because the
2626
// `nix` interfaces don't exist when compiling under
@@ -43,11 +43,11 @@ impl Pipe {
4343

4444
Ok(Self {
4545
// QEMU adds the "\\.\pipe\" prefix automatically.
46-
qemu_arg: format!("pipe:{}", base_name),
46+
qemu_arg: format!("pipe:{base_name}"),
4747

4848
// On Windows the pipe is duplex, so only one path
4949
// needed.
50-
input_path: format!(r"\\.\pipe\{}", base_name).into(),
50+
input_path: format!(r"\\.\pipe\{base_name}").into(),
5151
output_path: PathBuf::new(),
5252
})
5353
} else {

xtask/src/qemu.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ fn echo_filtered_stdout<R: Read, W: Write>(mut child_io: Io<R, W>) {
289289
let stripped = String::from_utf8(stripped.into()).expect("line is not utf8");
290290

291291
// Print out the processed QEMU output for logging & inspection.
292-
println!("{}", stripped);
292+
println!("{stripped}");
293293
}
294294
}
295295

@@ -334,7 +334,7 @@ fn process_qemu_io<R: Read, W: Write>(
334334
// Compare screenshot to the reference file specified by the user.
335335
// TODO: Add an operating mode where the reference is created if it doesn't exist.
336336
let reference_file =
337-
Path::new("uefi-test-runner/screenshots").join(format!("{}.ppm", reference_name));
337+
Path::new("uefi-test-runner/screenshots").join(format!("{reference_name}.ppm"));
338338
let expected = fs_err::read(reference_file)?;
339339
let actual = fs_err::read(&screenshot_path)?;
340340
assert_eq!(expected, actual);
@@ -390,10 +390,10 @@ impl Drop for ChildWrapper {
390390
// Try to stop the process, then wait for it to exit. Log errors
391391
// but otherwise ignore.
392392
if let Err(err) = self.0.kill() {
393-
eprintln!("failed to kill process: {}", err);
393+
eprintln!("failed to kill process: {err}");
394394
}
395395
if let Err(err) = self.0.wait() {
396-
eprintln!("failed to wait for process exit: {}", err);
396+
eprintln!("failed to wait for process exit: {err}");
397397
}
398398
}
399399
}
@@ -564,7 +564,7 @@ pub fn run_qemu(arch: UefiArch, opt: &QemuOpt) -> Result<()> {
564564
// terminated by a signal.
565565
let qemu_exit_code = status
566566
.code()
567-
.context(format!("qemu was terminated by a signal: {:?}", status))?;
567+
.context(format!("qemu was terminated by a signal: {status:?}"))?;
568568

569569
let successful_exit_code = match arch {
570570
UefiArch::AArch64 | UefiArch::IA32 => 0,

0 commit comments

Comments
 (0)