mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Inline all format arguments where possible
This makes code more readale and concise, moving all format arguments like `format!("{}", foo)` into the more compact `format!("{foo}")` form. The change was automatically created with, so there are far less change of an accidental typo. ``` cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args ```
This commit is contained in:
parent
1927c2e1d8
commit
e16c76e3c3
180 changed files with 487 additions and 501 deletions
|
@ -238,7 +238,7 @@ impl ProfileStack {
|
|||
self.heartbeat(frame.heartbeats);
|
||||
let avg_span = duration / (frame.heartbeats + 1);
|
||||
if avg_span > self.filter.heartbeat_longer_than {
|
||||
eprintln!("Too few heartbeats {} ({}/{:?})?", label, frame.heartbeats, duration);
|
||||
eprintln!("Too few heartbeats {label} ({}/{duration:?})?", frame.heartbeats);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ fn print(
|
|||
out: &mut impl Write,
|
||||
) {
|
||||
let current_indent = " ".repeat(level as usize);
|
||||
let detail = tree[curr].detail.as_ref().map(|it| format!(" @ {}", it)).unwrap_or_default();
|
||||
let detail = tree[curr].detail.as_ref().map(|it| format!(" @ {it}")).unwrap_or_default();
|
||||
writeln!(
|
||||
out,
|
||||
"{}{} - {}{}",
|
||||
|
@ -302,13 +302,13 @@ fn print(
|
|||
}
|
||||
|
||||
for (child_msg, (duration, count)) in &short_children {
|
||||
writeln!(out, " {}{} - {} ({} calls)", current_indent, ms(*duration), child_msg, count)
|
||||
writeln!(out, " {current_indent}{} - {child_msg} ({count} calls)", ms(*duration))
|
||||
.expect("printing profiling info");
|
||||
}
|
||||
|
||||
let unaccounted = tree[curr].duration - accounted_for;
|
||||
if tree.children(curr).next().is_some() && unaccounted > longer_than {
|
||||
writeln!(out, " {}{} - ???", current_indent, ms(unaccounted))
|
||||
writeln!(out, " {current_indent}{} - ???", ms(unaccounted))
|
||||
.expect("printing profiling info");
|
||||
}
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ impl fmt::Display for ms {
|
|||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self.0.as_millis() {
|
||||
0 => f.write_str(" 0 "),
|
||||
n => write!(f, "{:5}ms", n),
|
||||
n => write!(f, "{n:5}ms"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ impl fmt::Display for Bytes {
|
|||
suffix = "mb";
|
||||
}
|
||||
}
|
||||
f.pad(&format!("{}{}", value, suffix))
|
||||
f.pad(&format!("{value}{suffix}"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,11 +33,11 @@ impl StopWatch {
|
|||
if *PERF_ENABLED {
|
||||
let mut counter = perf_event::Builder::new()
|
||||
.build()
|
||||
.map_err(|err| eprintln!("Failed to create perf counter: {}", err))
|
||||
.map_err(|err| eprintln!("Failed to create perf counter: {err}"))
|
||||
.ok();
|
||||
if let Some(counter) = &mut counter {
|
||||
if let Err(err) = counter.enable() {
|
||||
eprintln!("Failed to start perf counter: {}", err)
|
||||
eprintln!("Failed to start perf counter: {err}")
|
||||
}
|
||||
}
|
||||
counter
|
||||
|
@ -64,7 +64,7 @@ impl StopWatch {
|
|||
|
||||
#[cfg(target_os = "linux")]
|
||||
let instructions = self.counter.as_mut().and_then(|it| {
|
||||
it.read().map_err(|err| eprintln!("Failed to read perf counter: {}", err)).ok()
|
||||
it.read().map_err(|err| eprintln!("Failed to read perf counter: {err}")).ok()
|
||||
});
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
let instructions = None;
|
||||
|
@ -91,10 +91,10 @@ impl fmt::Display for StopWatchSpan {
|
|||
instructions /= 1000;
|
||||
prefix = "g";
|
||||
}
|
||||
write!(f, ", {}{}instr", instructions, prefix)?;
|
||||
write!(f, ", {instructions}{prefix}instr")?;
|
||||
}
|
||||
if let Some(memory) = self.memory {
|
||||
write!(f, ", {}", memory)?;
|
||||
write!(f, ", {memory}")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue