Skip to content

Commit a4c477b

Browse files
committed
Apply clippy::uninlined_format_args fixes
1 parent efbb487 commit a4c477b

24 files changed

+77
-83
lines changed

build.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ fn get_git_sha() -> Option<String> {
1515
let symbolic = cmd(&["git", "rev-parse", "--symbolic", "HEAD"]).unwrap();
1616
let symbolic_full = cmd(&["git", "rev-parse", "--symbolic-full-name", "HEAD"]).unwrap();
1717

18-
println!("cargo:rerun-if-changed=.git/{}", symbolic);
18+
println!("cargo:rerun-if-changed=.git/{symbolic}");
1919
if symbolic != symbolic_full {
20-
println!("cargo:rerun-if-changed=.git/{}", symbolic_full);
20+
println!("cargo:rerun-if-changed=.git/{symbolic_full}");
2121
}
2222

2323
Some(sha)
@@ -31,5 +31,5 @@ fn main() {
3131
let sha = format!("{:?}", get_git_sha());
3232

3333
let output = std::env::var("OUT_DIR").unwrap();
34-
::std::fs::write(format!("{}/sha", output), sha.as_bytes()).unwrap();
34+
::std::fs::write(format!("{output}/sha"), sha.as_bytes()).unwrap();
3535
}

src/actions/experiments/edit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Action for EditExperiment {
5757
}
5858

5959
let changes = t.execute(
60-
&format!("UPDATE experiments SET {} = ?1 WHERE name = ?2;", col),
60+
&format!("UPDATE experiments SET {col} = ?1 WHERE name = ?2;"),
6161
&[&ex.toolchains[i].to_string(), &self.name],
6262
)?;
6363
assert_eq!(changes, 1);

src/agent/api.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl ResponseExt for ::reqwest::blocking::Response {
5151
let status = self.status();
5252
let result: ApiResponse<T> = self
5353
.json()
54-
.with_context(|_| format!("failed to parse API response (status code {})", status,))?;
54+
.with_context(|_| format!("failed to parse API response (status code {status})",))?;
5555
match result {
5656
ApiResponse::Success { result } => Ok(result),
5757
ApiResponse::SlowDown => Err(AgentApiError::ServerUnavailable.into()),
@@ -78,7 +78,7 @@ impl AgentApi {
7878
}
7979

8080
fn build_request(&self, method: Method, url: &str) -> RequestBuilder {
81-
utils::http::prepare_sync(method, &format!("{}/agent-api/{}", self.url, url)).header(
81+
utils::http::prepare_sync(method, &format!("{}/agent-api/{url}", self.url)).header(
8282
AUTHORIZATION,
8383
(CraterToken {
8484
token: self.token.clone(),
@@ -101,7 +101,7 @@ impl AgentApi {
101101
// We retry these errors. Ideally it's something the
102102
// server would handle, but that's (unfortunately) hard
103103
// in practice.
104-
format!("{:?}", err).contains("database is locked")
104+
format!("{err:?}").contains("database is locked")
105105
};
106106

107107
if retry {

src/crates/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ impl Crate {
3535
Crate::Registry(ref details) => format!("reg/{}/{}", details.name, details.version),
3636
Crate::GitHub(ref repo) => {
3737
if let Some(ref sha) = repo.sha {
38-
format!("gh/{}/{}/{}", repo.org, repo.name, sha)
38+
format!("gh/{}/{}/{sha}", repo.org, repo.name)
3939
} else {
4040
format!("gh/{}/{}", repo.org, repo.name)
4141
}
4242
}
43-
Crate::Local(ref name) => format!("local/{}", name),
43+
Crate::Local(ref name) => format!("local/{name}"),
4444
Crate::Path(ref path) => {
4545
format!("path/{}", utf8_percent_encode(path, NON_ALPHANUMERIC))
4646
}
@@ -132,11 +132,11 @@ impl fmt::Display for Crate {
132132
Crate::Registry(ref krate) => format!("{}-{}", krate.name, krate.version),
133133
Crate::GitHub(ref repo) =>
134134
if let Some(ref sha) = repo.sha {
135-
format!("{}/{}/{}", repo.org, repo.name, sha)
135+
format!("{}/{}/{sha}", repo.org, repo.name)
136136
} else {
137137
format!("{}/{}", repo.org, repo.name)
138138
},
139-
Crate::Local(ref name) => format!("{} (local)", name),
139+
Crate::Local(ref name) => format!("{name} (local)"),
140140
Crate::Path(ref path) => format!("{}", utf8_percent_encode(path, NON_ALPHANUMERIC)),
141141
Crate::Git(ref repo) =>
142142
if let Some(ref sha) = repo.sha {

src/db/migrations.rs

+7-13
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ fn migrations() -> Vec<(&'static str, MigrationKind)> {
153153
if let Ok(parsed) = serde_json::from_str(&legacy) {
154154
Ok(match parsed {
155155
LegacyToolchain::Dist(name) => name,
156-
LegacyToolchain::TryBuild { sha } => format!("try#{}", sha),
157-
LegacyToolchain::Master { sha } => format!("master#{}", sha),
156+
LegacyToolchain::TryBuild { sha } => format!("try#{sha}"),
157+
LegacyToolchain::Master { sha } => format!("master#{sha}"),
158158
})
159159
} else {
160160
Ok(legacy)
@@ -178,7 +178,7 @@ fn migrations() -> Vec<(&'static str, MigrationKind)> {
178178
[],
179179
)?;
180180
t.execute(
181-
&format!("UPDATE results SET toolchain = {}(toolchain);", fn_name),
181+
&format!("UPDATE results SET toolchain = {fn_name}(toolchain);"),
182182
[],
183183
)?;
184184
t.execute("PRAGMA foreign_keys = ON;", [])?;
@@ -352,17 +352,11 @@ fn migrations() -> Vec<(&'static str, MigrationKind)> {
352352

353353
t.execute("PRAGMA foreign_keys = OFF;", [])?;
354354
t.execute(
355-
&format!("UPDATE experiment_crates SET crate = {}(crate);", fn_name),
356-
[],
357-
)?;
358-
t.execute(
359-
&format!("UPDATE results SET crate = {}(crate);", fn_name),
360-
[],
361-
)?;
362-
t.execute(
363-
&format!("UPDATE crates SET crate = {}(crate);", fn_name),
355+
&format!("UPDATE experiment_crates SET crate = {fn_name}(crate);"),
364356
[],
365357
)?;
358+
t.execute(&format!("UPDATE results SET crate = {fn_name}(crate);"), [])?;
359+
t.execute(&format!("UPDATE crates SET crate = {fn_name}(crate);"), [])?;
366360
t.execute("PRAGMA foreign_keys = ON;", [])?;
367361

368362
Ok(())
@@ -406,7 +400,7 @@ pub fn execute(db: &mut Connection) -> Fallible<()> {
406400
MigrationKind::SQL(sql) => t.execute_batch(sql),
407401
MigrationKind::Code(code) => code(&t),
408402
}
409-
.with_context(|_| format!("error running migration: {}", name))?;
403+
.with_context(|_| format!("error running migration: {name}"))?;
410404

411405
t.execute("INSERT INTO migrations (name) VALUES (?1)", [&name])?;
412406
t.commit()?;

src/experiments.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ impl fmt::Display for CrateSelect {
9797
CrateSelect::Full => write!(f, "full"),
9898
CrateSelect::Demo => write!(f, "demo"),
9999
CrateSelect::Dummy => write!(f, "dummy"),
100-
CrateSelect::Top(n) => write!(f, "top-{}", n),
100+
CrateSelect::Top(n) => write!(f, "top-{n}"),
101101
CrateSelect::Local => write!(f, "local"),
102-
CrateSelect::Random(n) => write!(f, "random-{}", n),
102+
CrateSelect::Random(n) => write!(f, "random-{n}"),
103103
CrateSelect::List(list) => {
104104
let mut first = true;
105105
write!(f, "list:")?;
@@ -109,7 +109,7 @@ impl fmt::Display for CrateSelect {
109109
write!(f, ",")?;
110110
}
111111

112-
write!(f, "{}", krate)?;
112+
write!(f, "{krate}")?;
113113
first = false;
114114
}
115115

@@ -178,7 +178,7 @@ pub enum Assignee {
178178
impl fmt::Display for Assignee {
179179
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
180180
match self {
181-
Assignee::Agent(ref name) => write!(f, "agent:{}", name),
181+
Assignee::Agent(ref name) => write!(f, "agent:{name}"),
182182
Assignee::Distributed => write!(f, "distributed"),
183183
Assignee::CLI => write!(f, "cli"),
184184
}

src/report/archives.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn iterate<'a, DB: ReadResults + 'a>(
5050
let log = db
5151
.load_log(ex, tc, krate)
5252
.and_then(|c| c.ok_or_else(|| err_msg("missing logs")))
53-
.with_context(|_| format!("failed to read log of {} on {}", krate, tc));
53+
.with_context(|_| format!("failed to read log of {krate} on {tc}"));
5454

5555
let log_bytes: EncodedLog = match log {
5656
Ok(l) => l,
@@ -163,15 +163,15 @@ pub fn write_logs_archives<DB: ReadResults, W: ReportWriter>(
163163
for (comparison, archive) in by_comparison.drain(..) {
164164
let data = archive.into_inner()?.finish()?;
165165
dest.write_bytes(
166-
format!("logs-archives/{}.tar.gz", comparison),
166+
format!("logs-archives/{comparison}.tar.gz"),
167167
data,
168168
&"application/gzip".parse().unwrap(),
169169
EncodingType::Plain,
170170
)?;
171171

172172
archives.push(Archive {
173-
name: format!("{} crates", comparison),
174-
path: format!("logs-archives/{}.tar.gz", comparison),
173+
name: format!("{comparison} crates"),
174+
path: format!("logs-archives/{comparison}.tar.gz"),
175175
});
176176
}
177177

src/report/markdown.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn write_crate(
6666
let prefix = if is_child { " * " } else { "* " };
6767
let status_warning = krate
6868
.status
69-
.map(|status| format!(" ({})", status))
69+
.map(|status| format!(" ({status})"))
7070
.unwrap_or_default();
7171

7272
if let ReportConfig::Complete(toolchain) = comparison.report_config() {
@@ -106,7 +106,7 @@ fn render_markdown(context: &ResultsContext) -> Fallible<String> {
106106
writeln!(rendered, "# Crater report for {}\n\n", context.ex.name)?;
107107

108108
for (comparison, results) in context.categories.iter() {
109-
writeln!(rendered, "\n### {}", comparison)?;
109+
writeln!(rendered, "\n### {comparison}")?;
110110
match results {
111111
ReportCratesMD::Plain(crates) => {
112112
for krate in crates {

src/report/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ fn write_logs<DB: ReadResults, W: ReportWriter>(
293293
let content = db
294294
.load_log(ex, tc, krate)
295295
.and_then(|c| c.ok_or_else(|| err_msg("missing logs")))
296-
.with_context(|_| format!("failed to read log of {} on {}", krate, tc));
296+
.with_context(|_| format!("failed to read log of {krate} on {tc}"));
297297
let content = match content {
298298
Ok(c) => c,
299299
Err(e) => {
@@ -392,12 +392,12 @@ fn crate_to_name(c: &Crate) -> String {
392392
Crate::Registry(ref details) => format!("{}-{}", details.name, details.version),
393393
Crate::GitHub(ref repo) => {
394394
if let Some(ref sha) = repo.sha {
395-
format!("{}.{}.{}", repo.org, repo.name, sha)
395+
format!("{}.{}.{sha}", repo.org, repo.name)
396396
} else {
397397
format!("{}.{}", repo.org, repo.name)
398398
}
399399
}
400-
Crate::Local(ref name) => format!("{} (local)", name),
400+
Crate::Local(ref name) => format!("{name} (local)"),
401401
Crate::Path(ref path) => utf8_percent_encode(path, &REPORT_ENCODE_SET).to_string(),
402402
Crate::Git(ref repo) => {
403403
if let Some(ref sha) = repo.sha {
@@ -421,7 +421,7 @@ fn crate_to_url(c: &Crate) -> String {
421421
),
422422
Crate::GitHub(ref repo) => {
423423
if let Some(ref sha) = repo.sha {
424-
format!("https://github.com/{}/{}/tree/{}", repo.org, repo.name, sha)
424+
format!("https://github.com/{}/{}/tree/{sha}", repo.org, repo.name)
425425
} else {
426426
format!("https://github.com/{}/{}", repo.org, repo.name)
427427
}
@@ -499,7 +499,7 @@ fn compare(
499499
| (TestPass, TestSkipped)
500500
| (TestSkipped, TestFail(_))
501501
| (TestSkipped, TestPass) => {
502-
panic!("can't compare {} and {}", res1, res2);
502+
panic!("can't compare {res1} and {res2}");
503503
}
504504
},
505505
_ if config.should_skip(krate) => Comparison::Skipped,

src/report/s3.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ mod tests {
229229
"s3://bucket:80",
230230
"s3://bucket/path/prefix?query#fragment",
231231
] {
232-
assert!(S3Prefix::from_str(bad).is_err(), "valid bad url: {}", bad);
232+
assert!(S3Prefix::from_str(bad).is_err(), "valid bad url: {bad}");
233233
}
234234
}
235235
}

src/runner/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub fn run_ex<DB: WriteResults + Sync>(
111111
let workers = (0..threads_count)
112112
.map(|i| {
113113
Worker::new(
114-
format!("worker-{}", i),
114+
format!("worker-{i}"),
115115
workspace,
116116
ex,
117117
config,

src/runner/tasks.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ impl fmt::Debug for TaskStep {
7474
TaskStep::UnstableFeatures { ref tc } => ("find unstable features on", false, Some(tc)),
7575
};
7676

77-
write!(f, "{}", name)?;
77+
write!(f, "{name}")?;
7878
if let Some(tc) = tc {
79-
write!(f, " {}", tc)?;
79+
write!(f, " {tc}")?;
8080
}
8181
if quiet {
8282
write!(f, " (quiet)")?;

src/server/auth.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl ACL {
168168
let members = github.team_members(
169169
*orgs[org]
170170
.get(team)
171-
.ok_or_else(|| err_msg(format!("team {}/{} doesn't exist", org, team)))?,
171+
.ok_or_else(|| err_msg(format!("team {org}/{team} doesn't exist")))?,
172172
)?;
173173
for member in &members {
174174
new_cache.insert(member.clone());
@@ -206,11 +206,11 @@ mod tests {
206206
fn test_git_revision() {
207207
for sha in &["0000000", "0000000000000000000000000000000000000000"] {
208208
assert_eq!(
209-
git_revision(&format!("crater/{}", sha)),
209+
git_revision(&format!("crater/{sha}")),
210210
Some(sha.to_string())
211211
);
212212
assert_eq!(
213-
git_revision(&format!("crater/{} (foo bar!)", sha)),
213+
git_revision(&format!("crater/{sha} (foo bar!)")),
214214
Some(sha.to_string())
215215
);
216216
}

src/server/github.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl GitHubApi {
3939

4040
fn build_request(&self, method: Method, url: &str) -> RequestBuilder {
4141
let url = if !url.starts_with("https://") {
42-
format!("https://api.github.com/{}", url)
42+
format!("https://api.github.com/{url}")
4343
} else {
4444
url.to_string()
4545
};
@@ -57,7 +57,7 @@ impl GitHub for GitHubApi {
5757

5858
fn post_comment(&self, issue_url: &str, body: &str) -> Fallible<()> {
5959
let response = self
60-
.build_request(Method::POST, &format!("{}/comments", issue_url))
60+
.build_request(Method::POST, &format!("{issue_url}/comments"))
6161
.json(&json!({
6262
"body": body,
6363
}))
@@ -74,7 +74,7 @@ impl GitHub for GitHubApi {
7474

7575
fn list_labels(&self, issue_url: &str) -> Fallible<Vec<Label>> {
7676
let response = self
77-
.build_request(Method::GET, &format!("{}/labels", issue_url))
77+
.build_request(Method::GET, &format!("{issue_url}/labels"))
7878
.send()?;
7979

8080
let status = response.status();
@@ -88,7 +88,7 @@ impl GitHub for GitHubApi {
8888

8989
fn add_label(&self, issue_url: &str, label: &str) -> Fallible<()> {
9090
let response = self
91-
.build_request(Method::POST, &format!("{}/labels", issue_url))
91+
.build_request(Method::POST, &format!("{issue_url}/labels"))
9292
.json(&json!([label]))
9393
.send()?;
9494

@@ -103,7 +103,7 @@ impl GitHub for GitHubApi {
103103

104104
fn remove_label(&self, issue_url: &str, label: &str) -> Fallible<()> {
105105
let response = self
106-
.build_request(Method::DELETE, &format!("{}/labels/{}", issue_url, label))
106+
.build_request(Method::DELETE, &format!("{issue_url}/labels/{label}"))
107107
.send()?;
108108

109109
let status = response.status();
@@ -117,7 +117,7 @@ impl GitHub for GitHubApi {
117117

118118
fn list_teams(&self, org: &str) -> Fallible<HashMap<String, usize>> {
119119
let response = self
120-
.build_request(Method::GET, &format!("orgs/{}/teams", org))
120+
.build_request(Method::GET, &format!("orgs/{org}/teams"))
121121
.send()?;
122122

123123
let status = response.status();
@@ -132,7 +132,7 @@ impl GitHub for GitHubApi {
132132

133133
fn team_members(&self, team: usize) -> Fallible<Vec<String>> {
134134
let response = self
135-
.build_request(Method::GET, &format!("teams/{}/members", team))
135+
.build_request(Method::GET, &format!("teams/{team}/members"))
136136
.send()?;
137137

138138
let status = response.status();
@@ -147,7 +147,7 @@ impl GitHub for GitHubApi {
147147

148148
fn get_commit(&self, repo: &str, sha: &str) -> Fallible<Commit> {
149149
let commit = self
150-
.build_request(Method::GET, &format!("repos/{}/commits/{}", repo, sha))
150+
.build_request(Method::GET, &format!("repos/{repo}/commits/{sha}"))
151151
.send()?
152152
.error_for_status()?
153153
.json()?;
@@ -156,7 +156,7 @@ impl GitHub for GitHubApi {
156156

157157
fn get_pr_head_sha(&self, repo: &str, pr: i32) -> Fallible<String> {
158158
let pr: PullRequestData = self
159-
.build_request(Method::GET, &format!("repos/{}/pulls/{}", repo, pr))
159+
.build_request(Method::GET, &format!("repos/{repo}/pulls/{pr}"))
160160
.send()?
161161
.error_for_status()?
162162
.json()?;

0 commit comments

Comments
 (0)