Skip to content

Commit 16fca1a

Browse files
committed
Fix Clippy
1 parent d1273ef commit 16fca1a

37 files changed

+147
-165
lines changed

collector/benchlib/src/benchmark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<'a> BenchmarkGroup<'a> {
5858
profile_fn: Box::new(move || profile_function(constructor2.as_ref())),
5959
};
6060
if self.benchmarks.insert(name, benchmark_fns).is_some() {
61-
panic!("Benchmark '{}' was registered twice", name);
61+
panic!("Benchmark '{name}' was registered twice");
6262
}
6363
}
6464

collector/src/bin/collector.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ use database::{ArtifactId, ArtifactIdNumber, Commit, CommitType, Connection, Poo
6262

6363
fn n_normal_benchmarks_remaining(n: usize) -> String {
6464
let suffix = if n == 1 { "" } else { "s" };
65-
format!("{} normal benchmark{} remaining", n, suffix)
65+
format!("{n} normal benchmark{suffix} remaining")
6666
}
6767

6868
struct BenchmarkErrors(usize);
@@ -160,7 +160,7 @@ fn generate_diffs(
160160
vec![format!("{:?}", scenario)]
161161
}
162162
Scenario::IncrPatched => (0..benchmark.patches.len())
163-
.map(|i| format!("{:?}{}", scenario, i))
163+
.map(|i| format!("{scenario:?}{i}"))
164164
.collect::<Vec<_>>(),
165165
}
166166
}) {
@@ -175,15 +175,15 @@ fn generate_diffs(
175175
profiler.postfix()
176176
)
177177
};
178-
let id_diff = format!("{}-{}", id1, id2);
178+
let id_diff = format!("{id1}-{id2}");
179179
let prefix = profiler.prefix();
180180
let left = out_dir.join(filename(prefix, id1));
181181
let right = out_dir.join(filename(prefix, id2));
182182
let output = out_dir.join(filename(&format!("{prefix}-diff"), &id_diff));
183183

184184
if let Err(e) = profiler.diff(&left, &right, &output) {
185185
errors.incr();
186-
eprintln!("collector error: {:?}", e);
186+
eprintln!("collector error: {e:?}");
187187
continue;
188188
}
189189

@@ -249,7 +249,7 @@ fn main() {
249249
match main_result() {
250250
Ok(code) => process::exit(code),
251251
Err(err) => {
252-
eprintln!("collector error: {:?}", err);
252+
eprintln!("collector error: {err:?}");
253253
process::exit(1);
254254
}
255255
}
@@ -998,7 +998,7 @@ fn main_result() -> anyhow::Result<i32> {
998998
println!("processing artifacts");
999999
let client = reqwest::blocking::Client::new();
10001000
let response: collector::api::next_artifact::Response = client
1001-
.get(format!("{}/perf/next_artifact", site_url))
1001+
.get(format!("{site_url}/perf/next_artifact"))
10021002
.send()?
10031003
.json()?;
10041004
let next = if let Some(c) = response.artifact {
@@ -1065,7 +1065,7 @@ fn main_result() -> anyhow::Result<i32> {
10651065
let sysroot = rt
10661066
.block_on(Sysroot::install(sha.clone(), &host_target_tuple, &backends))
10671067
.with_context(|| {
1068-
format!("failed to install sysroot for {:?}", commit)
1068+
format!("failed to install sysroot for {commit:?}")
10691069
})?;
10701070

10711071
let mut benchmarks = get_compile_benchmarks(
@@ -1126,7 +1126,7 @@ fn main_result() -> anyhow::Result<i32> {
11261126
}
11271127
});
11281128
// We need to send a message to this endpoint even if the collector panics
1129-
client.post(format!("{}/perf/onpush", site_url)).send()?;
1129+
client.post(format!("{site_url}/perf/onpush")).send()?;
11301130

11311131
match res {
11321132
Ok(res) => res?,
@@ -1366,7 +1366,7 @@ Make sure to modify `{dir}/perf-config.json` if the category/artifact don't matc
13661366

13671367
if let Some(benchmark_job) = benchmark_job {
13681368
// TODO; process the job
1369-
println!("{:?}", benchmark_job);
1369+
println!("{benchmark_job:?}");
13701370
}
13711371

13721372
Ok(0)
@@ -1658,7 +1658,7 @@ fn print_binary_stats(
16581658
.corner_top_right('│'),
16591659
),
16601660
);
1661-
println!("{}", table);
1661+
println!("{table}");
16621662
}
16631663

16641664
fn get_local_toolchain_for_runtime_benchmarks(
@@ -1929,15 +1929,14 @@ async fn bench_compile(
19291929
let result = measure(&mut processor).await;
19301930
if let Err(s) = result {
19311931
eprintln!(
1932-
"collector error: Failed to benchmark '{}', recorded: {:#}",
1933-
benchmark_name, s
1932+
"collector error: Failed to benchmark '{benchmark_name}', recorded: {s:#}"
19341933
);
19351934
errors.incr();
19361935
tx.conn()
19371936
.record_error(
19381937
collector.artifact_row_id,
19391938
&benchmark_name.0,
1940-
&format!("{:?}", s),
1939+
&format!("{s:?}"),
19411940
)
19421941
.await;
19431942
};

collector/src/bin/rustc-fake.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ fn run_with_determinism_env(mut cmd: Command) {
3030
let status = cmd.status().expect("failed to spawn");
3131
assert!(
3232
status.success(),
33-
"command did not complete successfully: {:?}",
34-
cmd
33+
"command did not complete successfully: {cmd:?}"
3534
);
3635
}
3736

@@ -70,7 +69,7 @@ fn main() {
7069
.ok()
7170
.and_then(|v| v.parse::<u32>().ok())
7271
{
73-
args.push(OsString::from(format!("-Zthreads={}", count)));
72+
args.push(OsString::from(format!("-Zthreads={count}")));
7473
}
7574

7675
args.push(OsString::from("-Adeprecated"));
@@ -408,7 +407,7 @@ fn main() {
408407
}
409408

410409
_ => {
411-
panic!("unknown wrapper: {}", wrapper);
410+
panic!("unknown wrapper: {wrapper}");
412411
}
413412
}
414413
} else if args.iter().any(|arg| arg == "--skip-this-rustc") {
@@ -421,7 +420,7 @@ fn main() {
421420
.iter()
422421
.any(|arg| arg == "-vV" || arg == "--print=file-names")
423422
{
424-
eprintln!("{:?} {:?}", tool, args);
423+
eprintln!("{tool:?} {args:?}");
425424
eprintln!("exiting -- non-wrapped rustc");
426425
std::process::exit(1);
427426
}
@@ -441,7 +440,7 @@ fn process_self_profile_output(prof_out_dir: PathBuf, args: &[OsString]) {
441440
.and_then(|args| args[1].to_str())
442441
.expect("rustc to be invoked with crate name");
443442
println!("!self-profile-dir:{}", prof_out_dir.to_str().unwrap());
444-
println!("!self-profile-crate:{}", crate_name);
443+
println!("!self-profile-crate:{crate_name}");
445444
}
446445

447446
#[cfg(windows)]
@@ -456,9 +455,9 @@ fn exec(cmd: &mut Command) -> ! {
456455
#[cfg(unix)]
457456
fn exec(cmd: &mut Command) -> ! {
458457
use std::os::unix::prelude::*;
459-
let cmd_d = format!("{:?}", cmd);
458+
let cmd_d = format!("{cmd:?}");
460459
let error = cmd.exec();
461-
panic!("failed to exec `{}`: {}", cmd_d, error);
460+
panic!("failed to exec `{cmd_d}`: {error}");
462461
}
463462

464463
#[cfg(unix)]

collector/src/codegen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ fn write_diff<W: Write>(writer: &mut W, use_color: bool, diff: &CodegenDiff) ->
203203
style.apply_to(change)
204204
)?;
205205
} else {
206-
write!(writer, "{}{}", sign, change)?;
206+
write!(writer, "{sign}{change}")?;
207207
}
208208
}
209209
writeln!(writer, "-----------------------------")?;
@@ -227,7 +227,7 @@ fn get_codegen(
227227
}
228228
CodegenType::LLVM | CodegenType::MIR => {}
229229
}
230-
cmd.arg(format!("{}", function_index));
230+
cmd.arg(format!("{function_index}"));
231231

232232
Ok(String::from_utf8(command_output(&mut cmd)?.stdout)?)
233233
}

collector/src/compile/benchmark/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ impl Benchmark {
141141
let config: BenchmarkConfig = if config_path.exists() {
142142
serde_json::from_reader(
143143
File::open(&config_path)
144-
.with_context(|| format!("failed to open {:?}", config_path))?,
144+
.with_context(|| format!("failed to open {config_path:?}"))?,
145145
)
146-
.with_context(|| format!("failed to parse {:?}", config_path))?
146+
.with_context(|| format!("failed to parse {config_path:?}"))?
147147
} else {
148148
bail!("missing a perf-config.json file for `{}`", name);
149149
};
@@ -207,7 +207,7 @@ impl Benchmark {
207207
.ok()
208208
.and_then(|v| v.parse::<u32>().ok())
209209
{
210-
cargo_args.push(format!("-j{}", count));
210+
cargo_args.push(format!("-j{count}"));
211211
}
212212

213213
CargoProcess {
@@ -478,7 +478,7 @@ impl Benchmark {
478478

479479
// An incremental build with some changes (realistic
480480
// incremental case).
481-
let scenario_str = format!("IncrPatched{}", i);
481+
let scenario_str = format!("IncrPatched{i}");
482482
self.mk_cargo_process(toolchain, cwd, profile, backend, target)
483483
.incremental(true)
484484
.processor(
@@ -734,8 +734,8 @@ mod tests {
734734

735735
for benchmark in benchmarks {
736736
let dir = benchmark_dir.join(&benchmark.name.0);
737-
let cargo_toml = std::fs::read_to_string(&dir.join("Cargo.toml"))
738-
.expect(&format!("Cannot read Cargo.toml of {}", benchmark.name));
737+
let cargo_toml = std::fs::read_to_string(dir.join("Cargo.toml"))
738+
.unwrap_or_else(|_| panic!("Cannot read Cargo.toml of {}", benchmark.name));
739739
assert!(
740740
cargo_toml.contains("[workspace]"),
741741
"{} does not contain [workspace] in its Cargo.toml",

collector/src/compile/benchmark/target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl FromStr for Target {
2222
fn from_str(s: &str) -> Result<Self, Self::Err> {
2323
Ok(match s.to_ascii_lowercase().as_str() {
2424
"x86_64-unknown-linux-gnu" => Target::X86_64UnknownLinuxGnu,
25-
_ => return Err(format!("{} is not a valid target", s)),
25+
_ => return Err(format!("{s} is not a valid target")),
2626
})
2727
}
2828
}

collector/src/compile/execute/bencher.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl Processor for BenchProcessor<'_> {
244244
| DeserializeStatError::XperfError(..)
245245
| DeserializeStatError::IOError(..)),
246246
) => {
247-
panic!("process_perf_stat_output failed: {:?}", e);
247+
panic!("process_perf_stat_output failed: {e:?}");
248248
}
249249
}
250250
})
@@ -320,7 +320,7 @@ impl SelfProfileS3Upload {
320320
data.read_to_end(&mut compressed).expect("compressed");
321321
std::fs::write(upload.path(), &compressed).expect("write compressed profile data");
322322

323-
format!("self-profile-{}.mm_profdata.sz", collection)
323+
format!("self-profile-{collection}.mm_profdata.sz")
324324
}
325325
};
326326

@@ -345,7 +345,7 @@ impl SelfProfileS3Upload {
345345
let start = std::time::Instant::now();
346346
let status = self.0.wait().expect("waiting for child");
347347
if !status.success() {
348-
panic!("S3 upload failed: {:?}", status);
348+
panic!("S3 upload failed: {status:?}");
349349
}
350350

351351
log::trace!("uploaded to S3, additional wait: {:?}", start.elapsed());

collector/src/compile/execute/etw_parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fn parse_events(r: &mut dyn BufRead, headers: Vec<EventHeader>) -> anyhow::Resul
169169
.columns
170170
.iter()
171171
.position(|c| c == name)
172-
.unwrap_or_else(|| panic!("failed to find column {}", name))
172+
.unwrap_or_else(|| panic!("failed to find column {name}"))
173173
+ 1
174174
};
175175

@@ -222,7 +222,7 @@ fn parse_events(r: &mut dyn BufRead, headers: Vec<EventHeader>) -> anyhow::Resul
222222

223223
let pid = process_name[l_paren + 1..r_paran].trim();
224224
pid.parse()
225-
.unwrap_or_else(|_| panic!("failed to parse '{}' to pid", pid))
225+
.unwrap_or_else(|_| panic!("failed to parse '{pid}' to pid"))
226226
}
227227

228228
let mut buffer = Vec::new();

collector/src/compile/execute/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ pub enum PerfTool {
3838
impl PerfTool {
3939
fn name(&self) -> String {
4040
match self {
41-
PerfTool::BenchTool(b) => format!("{:?}", b),
42-
PerfTool::ProfileTool(p) => format!("{:?}", p),
41+
PerfTool::BenchTool(b) => format!("{b:?}"),
42+
PerfTool::ProfileTool(p) => format!("{p:?}"),
4343
}
4444
}
4545

@@ -265,7 +265,7 @@ impl<'a> CargoProcess<'a> {
265265
}
266266

267267
let out = command_output(&mut pkgid_cmd)
268-
.with_context(|| format!("failed to obtain pkgid in '{:?}'", cwd))?
268+
.with_context(|| format!("failed to obtain pkgid in '{cwd:?}'"))?
269269
.stdout;
270270
let package_id = str::from_utf8(&out).unwrap();
271271
Ok(package_id.trim().to_string())
@@ -671,8 +671,7 @@ fn process_stat_output(
671671
}
672672
if !pct.starts_with("100.") {
673673
panic!(
674-
"measurement of `{}` only active for {}% of the time",
675-
name, pct
674+
"measurement of `{name}` only active for {pct}% of the time"
676675
);
677676
}
678677
stats.insert(

collector/src/compile/execute/profiler.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl Processor for ProfileProcessor<'_> {
173173
} else if filename_str.ends_with(".mm_profdata") {
174174
utils::fs::rename(path, filepath(&zsp_dir, "Zsp.mm_profdata"))?;
175175
} else {
176-
panic!("unexpected file {:?}", path);
176+
panic!("unexpected file {path:?}");
177177
}
178178
}
179179
assert!(num_files == 3 || num_files == 1);
@@ -357,7 +357,7 @@ impl Processor for ProfileProcessor<'_> {
357357
continue;
358358
}
359359

360-
writeln!(&mut final_file, "{}", line)?;
360+
writeln!(&mut final_file, "{line}")?;
361361
}
362362
}
363363

@@ -399,10 +399,10 @@ impl Processor for ProfileProcessor<'_> {
399399
let cgu_file = filepath(&out_dir, cgu);
400400
let mut file = io::BufWriter::new(
401401
fs::File::create(&cgu_file)
402-
.with_context(|| format!("{:?}", cgu_file))?,
402+
.with_context(|| format!("{cgu_file:?}"))?,
403403
);
404404
for (name, linkage) in items {
405-
writeln!(&mut file, "{} {}", name, linkage)?;
405+
writeln!(&mut file, "{name} {linkage}")?;
406406
}
407407
}
408408
}

0 commit comments

Comments
 (0)