Skip to content

Commit d7ce4b8

Browse files
authored
refactor(clippy): fix updated warnings for rust 1.88 (#759)
Signed-off-by: Joseph Livesey <[email protected]>
1 parent e34bbe6 commit d7ce4b8

File tree

25 files changed

+82
-115
lines changed

25 files changed

+82
-115
lines changed

crates/attestation/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn derive_key_pair(
2222
deployment: &DeploymentId,
2323
index: u64,
2424
) -> Result<PrivateKeySigner, anyhow::Error> {
25-
let mut derivation_path = format!("m/{}/", epoch);
25+
let mut derivation_path = format!("m/{epoch}/");
2626
derivation_path.push_str(
2727
&deployment
2828
.to_string()
@@ -32,7 +32,7 @@ pub fn derive_key_pair(
3232
.collect::<Vec<String>>()
3333
.join("/"),
3434
);
35-
derivation_path.push_str(format!("/{}", index).as_str());
35+
derivation_path.push_str(format!("/{index}").as_str());
3636

3737
Ok(MnemonicBuilder::<English>::default()
3838
.derivation_path(&derivation_path)

crates/config/src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl Config {
8787

8888
if let Some(path) = filename {
8989
let mut config_content = std::fs::read_to_string(path)
90-
.map_err(|e| format!("Failed to read config file: {}", e))?;
90+
.map_err(|e| format!("Failed to read config file: {e}"))?;
9191
config_content = Self::substitute_env_vars(config_content)?;
9292
figment_config = figment_config.merge(Toml::string(&config_content));
9393
}
@@ -134,7 +134,7 @@ impl Config {
134134
Ok(value) => value,
135135
Err(_) => {
136136
missing_vars.push(var_name.to_string());
137-
format!("${{{}}}", var_name)
137+
format!("${{{var_name}}}")
138138
}
139139
}
140140
});
@@ -264,7 +264,7 @@ impl DatabaseConfig {
264264
password,
265265
database,
266266
} => {
267-
let postgres_url_str = format!("postgres://{}@{}/{}", user, host, database);
267+
let postgres_url_str = format!("postgres://{user}@{host}/{database}");
268268
let mut postgres_url =
269269
Url::parse(&postgres_url_str).expect("Failed to parse database_url");
270270
postgres_url

crates/dips/src/database.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub struct PsqlAgreementStore {
2222

2323
fn uint256_to_bigdecimal(value: &uint256, field: &str) -> Result<BigDecimal, DipsError> {
2424
BigDecimal::from_str(&value.to_string())
25-
.map_err(|e| DipsError::InvalidVoucher(format!("{}: {}", field, e)))
25+
.map_err(|e| DipsError::InvalidVoucher(format!("{field}: {e}")))
2626
}
2727

2828
#[async_trait]

crates/dips/src/ipfs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ impl IpfsFetcher for IpfsClient {
4848
.await
4949
.map_err(|e| {
5050
tracing::warn!("Failed to fetch subgraph manifest {}: {}", file, e);
51-
DipsError::SubgraphManifestUnavailable(format!("{}: {}", file, e))
51+
DipsError::SubgraphManifestUnavailable(format!("{file}: {e}"))
5252
})?;
5353

5454
let manifest: GraphManifest = serde_yaml::from_slice(&content).map_err(|e| {
5555
tracing::warn!("Failed to parse subgraph manifest {}: {}", file, e);
56-
DipsError::InvalidSubgraphManifest(format!("{}: {}", file, e))
56+
DipsError::InvalidSubgraphManifest(format!("{file}: {e}"))
5757
})?;
5858

5959
Ok(manifest)

crates/dips/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub enum DipsError {
176176
#[cfg(feature = "rpc")]
177177
impl From<DipsError> for tonic::Status {
178178
fn from(value: DipsError) -> Self {
179-
tonic::Status::internal(format!("{}", value))
179+
tonic::Status::internal(format!("{value}"))
180180
}
181181
}
182182

@@ -679,7 +679,7 @@ mod test {
679679

680680
let res = signed.validate(&domain, &payer_addr);
681681
match error {
682-
Some(_err) => assert!(matches!(res.unwrap_err(), _err), "case: {}", name),
682+
Some(_err) => assert!(matches!(res.unwrap_err(), _err), "case: {name}"),
683683
None => assert!(res.is_ok(), "case: {}, err: {}", name, res.unwrap_err()),
684684
}
685685
}
@@ -904,7 +904,7 @@ mod test {
904904
match (out, result) {
905905
(Ok(a), Ok(b)) => assert_eq!(a.into_bytes(), b),
906906
(Err(a), Err(b)) => assert_eq!(a.to_string(), b.to_string()),
907-
(a, b) => panic!("{:?} did not match {:?}", a, b),
907+
(a, b) => panic!("{a:?} did not match {b:?}"),
908908
}
909909
}
910910

crates/dips/src/server.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -128,22 +128,16 @@ impl IndexerDipsService for DipsServer {
128128
Err(e) => match e {
129129
// Invalid signature/authorization errors
130130
DipsError::InvalidSignature(msg) => Err(Status::invalid_argument(format!(
131-
"invalid signature: {}",
132-
msg
131+
"invalid signature: {msg}"
133132
))),
134133
DipsError::PayerNotAuthorised(addr) => Err(Status::invalid_argument(format!(
135-
"payer {} not authorized",
136-
addr
134+
"payer {addr} not authorized"
137135
))),
138-
DipsError::UnexpectedPayee { expected, actual } => {
139-
Err(Status::invalid_argument(format!(
140-
"voucher payee {} does not match expected address {}",
141-
actual, expected
142-
)))
143-
}
136+
DipsError::UnexpectedPayee { expected, actual } => Err(Status::invalid_argument(
137+
format!("voucher payee {actual} does not match expected address {expected}"),
138+
)),
144139
DipsError::SignerNotAuthorised(addr) => Err(Status::invalid_argument(format!(
145-
"signer {} not authorized",
146-
addr
140+
"signer {addr} not authorized"
147141
))),
148142

149143
// Deployment/manifest related errors - these should return Reject
@@ -159,8 +153,7 @@ impl IndexerDipsService for DipsServer {
159153

160154
// Other errors
161155
DipsError::AbiDecoding(msg) => Err(Status::invalid_argument(format!(
162-
"invalid request voucher: {}",
163-
msg
156+
"invalid request voucher: {msg}"
164157
))),
165158
_ => Err(Status::internal(e.to_string())),
166159
},

crates/monitor/src/client/subgraph_client.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ impl DeploymentClient {
8383
monitor_deployment_status(deployment, url)
8484
.await
8585
.unwrap_or_else(|_| {
86-
panic!(
87-
"Failed to initialize monitoring for deployment `{}`",
88-
deployment
89-
)
86+
panic!("Failed to initialize monitoring for deployment `{deployment}`")
9087
}),
9188
),
9289
None => None,
@@ -119,7 +116,7 @@ impl DeploymentClient {
119116
.json(&body);
120117

121118
if let Some(token) = self.query_auth_token.as_ref() {
122-
req = req.header(header::AUTHORIZATION, format!("Bearer {}", token));
119+
req = req.header(header::AUTHORIZATION, format!("Bearer {token}"));
123120
}
124121

125122
let reqwest_response = req.send().await?;
@@ -160,7 +157,7 @@ impl DeploymentClient {
160157
.body(body);
161158

162159
if let Some(token) = self.query_auth_token.as_ref() {
163-
req = req.header(header::AUTHORIZATION, format!("Bearer {}", token));
160+
req = req.header(header::AUTHORIZATION, format!("Bearer {token}"));
164161
}
165162

166163
Ok(req.send().await?)
@@ -335,7 +332,7 @@ mod test {
335332
mock_server_local
336333
.register(
337334
Mock::given(method("POST"))
338-
.and(path(format!("/subgraphs/id/{}", deployment)))
335+
.and(path(format!("/subgraphs/id/{deployment}")))
339336
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
340337
"data": {
341338
"user": {
@@ -350,7 +347,7 @@ mod test {
350347
mock_server_remote
351348
.register(
352349
Mock::given(method("POST"))
353-
.and(path(format!("/subgraphs/id/{}", deployment)))
350+
.and(path(format!("/subgraphs/id/{deployment}")))
354351
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
355352
"data": {
356353
"user": {
@@ -415,7 +412,7 @@ mod test {
415412
mock_server_local
416413
.register(
417414
Mock::given(method("POST"))
418-
.and(path(format!("/subgraphs/id/{}", deployment)))
415+
.and(path(format!("/subgraphs/id/{deployment}")))
419416
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
420417
"data": {
421418
"user": {
@@ -430,7 +427,7 @@ mod test {
430427
mock_server_remote
431428
.register(
432429
Mock::given(method("POST"))
433-
.and(path(format!("/subgraphs/id/{}", deployment)))
430+
.and(path(format!("/subgraphs/id/{deployment}")))
434431
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
435432
"data": {
436433
"user": {
@@ -495,7 +492,7 @@ mod test {
495492
mock_server_local
496493
.register(
497494
Mock::given(method("POST"))
498-
.and(path(format!("/subgraphs/id/{}", deployment)))
495+
.and(path(format!("/subgraphs/id/{deployment}")))
499496
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
500497
"data": {
501498
"user": {
@@ -510,7 +507,7 @@ mod test {
510507
mock_server_remote
511508
.register(
512509
Mock::given(method("POST"))
513-
.and(path(format!("/subgraphs/id/{}", deployment)))
510+
.and(path(format!("/subgraphs/id/{deployment}")))
514511
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
515512
"data": {
516513
"user": {

crates/monitor/src/escrow_accounts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async fn get_escrow_accounts_v1(
133133
// payments in the name of the sender.
134134
let response = escrow_subgraph
135135
.query::<EscrowAccountQuery, _>(escrow_account::Variables {
136-
indexer: format!("{:x?}", indexer_address),
136+
indexer: format!("{indexer_address:x?}"),
137137
thaw_end_timestamp: if reject_thawing_signers {
138138
U256::ZERO.to_string()
139139
} else {

crates/profiler/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn generate_filename(
7474
// Format the datetime (YYYY-MM-DD-HH_MM_SS)
7575
let formatted_time = datetime.format("%Y-%m-%d-%H_%M_%S").to_string();
7676

77-
let filename = format!("{}-{}-{}.{}", prefix, formatted_time, counter, extension);
77+
let filename = format!("{prefix}-{formatted_time}-{counter}.{extension}");
7878
Ok(Path::new(base_path).join(filename))
7979
}
8080

crates/service/src/metrics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn serve_metrics(host_and_port: SocketAddr) {
5252
tracing::error!("Error encoding metrics: {}", e);
5353
(
5454
StatusCode::INTERNAL_SERVER_ERROR,
55-
format!("Error encoding metrics: {}", e),
55+
format!("Error encoding metrics: {e}"),
5656
)
5757
}
5858
}

0 commit comments

Comments
 (0)