Skip to content

Commit 58920cb

Browse files
committed
Fix all remaining Clippy issues
1 parent b6e7004 commit 58920cb

File tree

8 files changed

+52
-44
lines changed

8 files changed

+52
-44
lines changed

collector/src/bin/collector.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use collector::benchmark::{
1313
use collector::{runtime, utils, CollectorCtx, CollectorStepBuilder};
1414
use database::{ArtifactId, Commit, CommitType, Connection, Pool};
1515
use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator};
16+
use std::cmp::Ordering;
1617
use std::ffi::OsStr;
1718
use std::fs;
1819
use std::fs::File;
@@ -57,6 +58,7 @@ impl BenchmarkErrors {
5758
}
5859
}
5960

61+
#[allow(clippy::too_many_arguments)]
6062
fn bench(
6163
rt: &mut Runtime,
6264
mut conn: Box<dyn Connection>,
@@ -326,6 +328,7 @@ fn cg_annotate(cgout: &Path, path: &Path) -> anyhow::Result<()> {
326328
Ok(())
327329
}
328330

331+
#[allow(clippy::too_many_arguments)]
329332
fn profile(
330333
compiler: Compiler,
331334
id: &str,
@@ -710,7 +713,7 @@ fn main_result() -> anyhow::Result<i32> {
710713
let pool = Pool::open(&db.db);
711714

712715
let suite = runtime::discover_benchmarks(&toolchain, &runtime_benchmark_dir)?;
713-
let artifact_id = ArtifactId::Tag(toolchain.id.clone());
716+
let artifact_id = ArtifactId::Tag(toolchain.id);
714717
let (conn, collector) = rt.block_on(async {
715718
let mut conn = pool.connection().await;
716719
let collector = CollectorStepBuilder::default()
@@ -770,8 +773,8 @@ fn main_result() -> anyhow::Result<i32> {
770773
let res = bench(
771774
&mut rt,
772775
conn,
773-
&profiles,
774-
&scenarios,
776+
profiles,
777+
scenarios,
775778
Compiler::from_toolchain(&toolchain, &target_triple),
776779
&benchmarks,
777780
Some(iterations),
@@ -953,16 +956,19 @@ fn main_result() -> anyhow::Result<i32> {
953956
scenarios,
954957
&mut errors,
955958
);
956-
if diffs.len() > 1 {
957-
eprintln!("Diffs:");
958-
for diff in diffs {
959-
eprintln!("{}", diff.to_string_lossy());
959+
match diffs.len().cmp(&1) {
960+
Ordering::Equal => {
961+
let short = out_dir.join("cgann-diff-latest");
962+
std::fs::copy(&diffs[0], &short).expect("copy to short path");
963+
eprintln!("Original diff at: {}", diffs[0].to_string_lossy());
964+
eprintln!("Short path: {}", short.to_string_lossy());
965+
}
966+
_ => {
967+
eprintln!("Diffs:");
968+
for diff in diffs {
969+
eprintln!("{}", diff.to_string_lossy());
970+
}
960971
}
961-
} else if diffs.len() == 1 {
962-
let short = out_dir.join("cgann-diff-latest");
963-
std::fs::copy(&diffs[0], &short).expect("copy to short path");
964-
eprintln!("Original diff at: {}", diffs[0].to_string_lossy());
965-
eprintln!("Short path: {}", short.to_string_lossy());
966972
}
967973
}
968974
} else {
@@ -1020,7 +1026,7 @@ async fn init_compile_collector(
10201026
) -> (Box<dyn Connection>, CollectorCtx) {
10211027
let mut conn = pool.connection().await;
10221028
let collector = CollectorStepBuilder::default()
1023-
.record_compile_benchmarks(&benchmarks, bench_rustc)
1029+
.record_compile_benchmarks(benchmarks, bench_rustc)
10241030
.start_collection(conn.as_mut(), artifact_id)
10251031
.await;
10261032
(conn, collector)

collector/src/runtime/mod.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::future::Future;
21
use std::io::{BufRead, BufReader};
32
use std::path::Path;
43
use std::process::{Command, Stdio};
@@ -91,25 +90,23 @@ async fn record_stats(
9190
rustc_perf_version: &str,
9291
result: BenchmarkResult,
9392
) {
94-
fn record<'a>(
93+
async fn record<'a>(
9594
conn: &'a dyn Connection,
9695
artifact_id: ArtifactIdNumber,
9796
collection_id: CollectionId,
9897
result: &'a BenchmarkResult,
9998
value: Option<u64>,
10099
metric: &'a str,
101-
) -> impl Future<Output = ()> + 'a {
102-
async move {
103-
if let Some(value) = value {
104-
conn.record_runtime_statistic(
105-
collection_id,
106-
artifact_id,
107-
&result.name,
108-
metric,
109-
value as f64,
110-
)
111-
.await;
112-
}
100+
) {
101+
if let Some(value) = value {
102+
conn.record_runtime_statistic(
103+
collection_id,
104+
artifact_id,
105+
&result.name,
106+
metric,
107+
value as f64,
108+
)
109+
.await;
113110
}
114111
}
115112

database/src/pool/postgres.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,11 @@ impl ConnectionManager for Postgres {
238238
.await
239239
.unwrap();
240240
let version: Option<i32> = version.get(0);
241-
for mid in (version.unwrap_or(0) as usize + 1)..MIGRATIONS.len() {
242-
let sql = MIGRATIONS[mid];
241+
for (mid, sql) in MIGRATIONS
242+
.iter()
243+
.enumerate()
244+
.skip(version.unwrap_or(0) as usize + 1)
245+
{
243246
let tx = client.transaction().await.unwrap();
244247
tx.batch_execute(sql).await.unwrap();
245248
tx.execute(

database/src/pool/sqlite.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ impl ConnectionManager for Sqlite {
361361
|row| row.get(0),
362362
)
363363
.unwrap();
364-
for mid in (version as usize + 1)..MIGRATIONS.len() {
365-
MIGRATIONS[mid].execute(&mut conn, mid as i32);
364+
for (mid, migration) in MIGRATIONS.iter().enumerate().skip(version as usize + 1) {
365+
migration.execute(&mut conn, mid as i32);
366366
}
367367
});
368368

site/src/request_handlers/dashboard.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub async fn handle_dashboard(ctxt: Arc<SiteCtxt>) -> ServerResult<dashboard::Re
8484
static ref STABLE_BENCHMARKS: Vec<String> = get_stable_benchmarks();
8585
}
8686

87-
let query = selector::CompileBenchmarkQuery::new()
87+
let query = selector::CompileBenchmarkQuery::default()
8888
.benchmark(selector::Selector::Subset(STABLE_BENCHMARKS.clone()))
8989
.metric(selector::Selector::One(Metric::WallTime));
9090

site/src/request_handlers/graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ async fn create_graph(
5858
let artifact_ids = artifact_ids_for_range(&ctxt, request.start, request.end);
5959
let mut series_iterator = ctxt
6060
.compile_statistic_series(
61-
CompileBenchmarkQuery::new()
61+
CompileBenchmarkQuery::default()
6262
.benchmark(Selector::One(request.benchmark))
6363
.profile(Selector::One(request.profile.parse()?))
6464
.scenario(Selector::One(request.scenario.parse()?))
@@ -101,7 +101,7 @@ async fn create_graphs(
101101

102102
let interpolated_responses: Vec<_> = ctxt
103103
.compile_statistic_series(
104-
CompileBenchmarkQuery::new()
104+
CompileBenchmarkQuery::default()
105105
.benchmark(benchmark_selector)
106106
.profile(profile_selector)
107107
.scenario(scenario_selector)

site/src/request_handlers/self_profile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ pub async fn handle_self_profile(
583583
.ok()
584584
.ok_or("sort_idx needs to be i32".to_string())?;
585585

586-
let query = selector::CompileBenchmarkQuery::new()
586+
let query = selector::CompileBenchmarkQuery::default()
587587
.benchmark(selector::Selector::One(bench_name.to_string()))
588588
.profile(selector::Selector::One(profile.parse().unwrap()))
589589
.scenario(selector::Selector::One(scenario))

site/src/selector.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,6 @@ pub struct CompileBenchmarkQuery {
190190
}
191191

192192
impl CompileBenchmarkQuery {
193-
pub fn new() -> Self {
194-
Self {
195-
benchmark: Selector::All,
196-
scenario: Selector::All,
197-
profile: Selector::All,
198-
metric: Selector::All,
199-
}
200-
}
201-
202193
pub fn benchmark(mut self, selector: Selector<String>) -> Self {
203194
self.benchmark = selector;
204195
self
@@ -229,6 +220,17 @@ impl CompileBenchmarkQuery {
229220
}
230221
}
231222

223+
impl Default for CompileBenchmarkQuery {
224+
fn default() -> Self {
225+
Self {
226+
benchmark: Selector::All,
227+
scenario: Selector::All,
228+
profile: Selector::All,
229+
metric: Selector::All,
230+
}
231+
}
232+
}
233+
232234
#[derive(Debug)]
233235
pub struct CompileBenchmarkKey {
234236
pub benchmark: Benchmark,

0 commit comments

Comments
 (0)