Skip to content

refactor(clippy): fix updated warnings for rust 1.88 #759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/attestation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn derive_key_pair(
deployment: &DeploymentId,
index: u64,
) -> Result<PrivateKeySigner, anyhow::Error> {
let mut derivation_path = format!("m/{}/", epoch);
let mut derivation_path = format!("m/{epoch}/");
derivation_path.push_str(
&deployment
.to_string()
Expand All @@ -32,7 +32,7 @@ pub fn derive_key_pair(
.collect::<Vec<String>>()
.join("/"),
);
derivation_path.push_str(format!("/{}", index).as_str());
derivation_path.push_str(format!("/{index}").as_str());

Ok(MnemonicBuilder::<English>::default()
.derivation_path(&derivation_path)
Expand Down
6 changes: 3 additions & 3 deletions crates/config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl Config {

if let Some(path) = filename {
let mut config_content = std::fs::read_to_string(path)
.map_err(|e| format!("Failed to read config file: {}", e))?;
.map_err(|e| format!("Failed to read config file: {e}"))?;
config_content = Self::substitute_env_vars(config_content)?;
figment_config = figment_config.merge(Toml::string(&config_content));
}
Expand Down Expand Up @@ -134,7 +134,7 @@ impl Config {
Ok(value) => value,
Err(_) => {
missing_vars.push(var_name.to_string());
format!("${{{}}}", var_name)
format!("${{{var_name}}}")
}
}
});
Expand Down Expand Up @@ -264,7 +264,7 @@ impl DatabaseConfig {
password,
database,
} => {
let postgres_url_str = format!("postgres://{}@{}/{}", user, host, database);
let postgres_url_str = format!("postgres://{user}@{host}/{database}");
let mut postgres_url =
Url::parse(&postgres_url_str).expect("Failed to parse database_url");
postgres_url
Expand Down
2 changes: 1 addition & 1 deletion crates/dips/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct PsqlAgreementStore {

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

#[async_trait]
Expand Down
4 changes: 2 additions & 2 deletions crates/dips/src/ipfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ impl IpfsFetcher for IpfsClient {
.await
.map_err(|e| {
tracing::warn!("Failed to fetch subgraph manifest {}: {}", file, e);
DipsError::SubgraphManifestUnavailable(format!("{}: {}", file, e))
DipsError::SubgraphManifestUnavailable(format!("{file}: {e}"))
})?;

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

Ok(manifest)
Expand Down
6 changes: 3 additions & 3 deletions crates/dips/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ pub enum DipsError {
#[cfg(feature = "rpc")]
impl From<DipsError> for tonic::Status {
fn from(value: DipsError) -> Self {
tonic::Status::internal(format!("{}", value))
tonic::Status::internal(format!("{value}"))
}
}

Expand Down Expand Up @@ -679,7 +679,7 @@ mod test {

let res = signed.validate(&domain, &payer_addr);
match error {
Some(_err) => assert!(matches!(res.unwrap_err(), _err), "case: {}", name),
Some(_err) => assert!(matches!(res.unwrap_err(), _err), "case: {name}"),
None => assert!(res.is_ok(), "case: {}, err: {}", name, res.unwrap_err()),
}
}
Expand Down Expand Up @@ -904,7 +904,7 @@ mod test {
match (out, result) {
(Ok(a), Ok(b)) => assert_eq!(a.into_bytes(), b),
(Err(a), Err(b)) => assert_eq!(a.to_string(), b.to_string()),
(a, b) => panic!("{:?} did not match {:?}", a, b),
(a, b) => panic!("{a:?} did not match {b:?}"),
}
}

Expand Down
21 changes: 7 additions & 14 deletions crates/dips/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,16 @@ impl IndexerDipsService for DipsServer {
Err(e) => match e {
// Invalid signature/authorization errors
DipsError::InvalidSignature(msg) => Err(Status::invalid_argument(format!(
"invalid signature: {}",
msg
"invalid signature: {msg}"
))),
DipsError::PayerNotAuthorised(addr) => Err(Status::invalid_argument(format!(
"payer {} not authorized",
addr
"payer {addr} not authorized"
))),
DipsError::UnexpectedPayee { expected, actual } => {
Err(Status::invalid_argument(format!(
"voucher payee {} does not match expected address {}",
actual, expected
)))
}
DipsError::UnexpectedPayee { expected, actual } => Err(Status::invalid_argument(
format!("voucher payee {actual} does not match expected address {expected}"),
)),
DipsError::SignerNotAuthorised(addr) => Err(Status::invalid_argument(format!(
"signer {} not authorized",
addr
"signer {addr} not authorized"
))),

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

// Other errors
DipsError::AbiDecoding(msg) => Err(Status::invalid_argument(format!(
"invalid request voucher: {}",
msg
"invalid request voucher: {msg}"
))),
_ => Err(Status::internal(e.to_string())),
},
Expand Down
21 changes: 9 additions & 12 deletions crates/monitor/src/client/subgraph_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ impl DeploymentClient {
monitor_deployment_status(deployment, url)
.await
.unwrap_or_else(|_| {
panic!(
"Failed to initialize monitoring for deployment `{}`",
deployment
)
panic!("Failed to initialize monitoring for deployment `{deployment}`")
}),
),
None => None,
Expand Down Expand Up @@ -119,7 +116,7 @@ impl DeploymentClient {
.json(&body);

if let Some(token) = self.query_auth_token.as_ref() {
req = req.header(header::AUTHORIZATION, format!("Bearer {}", token));
req = req.header(header::AUTHORIZATION, format!("Bearer {token}"));
}

let reqwest_response = req.send().await?;
Expand Down Expand Up @@ -160,7 +157,7 @@ impl DeploymentClient {
.body(body);

if let Some(token) = self.query_auth_token.as_ref() {
req = req.header(header::AUTHORIZATION, format!("Bearer {}", token));
req = req.header(header::AUTHORIZATION, format!("Bearer {token}"));
}

Ok(req.send().await?)
Expand Down Expand Up @@ -335,7 +332,7 @@ mod test {
mock_server_local
.register(
Mock::given(method("POST"))
.and(path(format!("/subgraphs/id/{}", deployment)))
.and(path(format!("/subgraphs/id/{deployment}")))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"data": {
"user": {
Expand All @@ -350,7 +347,7 @@ mod test {
mock_server_remote
.register(
Mock::given(method("POST"))
.and(path(format!("/subgraphs/id/{}", deployment)))
.and(path(format!("/subgraphs/id/{deployment}")))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"data": {
"user": {
Expand Down Expand Up @@ -415,7 +412,7 @@ mod test {
mock_server_local
.register(
Mock::given(method("POST"))
.and(path(format!("/subgraphs/id/{}", deployment)))
.and(path(format!("/subgraphs/id/{deployment}")))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"data": {
"user": {
Expand All @@ -430,7 +427,7 @@ mod test {
mock_server_remote
.register(
Mock::given(method("POST"))
.and(path(format!("/subgraphs/id/{}", deployment)))
.and(path(format!("/subgraphs/id/{deployment}")))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"data": {
"user": {
Expand Down Expand Up @@ -495,7 +492,7 @@ mod test {
mock_server_local
.register(
Mock::given(method("POST"))
.and(path(format!("/subgraphs/id/{}", deployment)))
.and(path(format!("/subgraphs/id/{deployment}")))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"data": {
"user": {
Expand All @@ -510,7 +507,7 @@ mod test {
mock_server_remote
.register(
Mock::given(method("POST"))
.and(path(format!("/subgraphs/id/{}", deployment)))
.and(path(format!("/subgraphs/id/{deployment}")))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"data": {
"user": {
Expand Down
2 changes: 1 addition & 1 deletion crates/monitor/src/escrow_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async fn get_escrow_accounts_v1(
// payments in the name of the sender.
let response = escrow_subgraph
.query::<EscrowAccountQuery, _>(escrow_account::Variables {
indexer: format!("{:x?}", indexer_address),
indexer: format!("{indexer_address:x?}"),
thaw_end_timestamp: if reject_thawing_signers {
U256::ZERO.to_string()
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/profiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn generate_filename(
// Format the datetime (YYYY-MM-DD-HH_MM_SS)
let formatted_time = datetime.format("%Y-%m-%d-%H_%M_%S").to_string();

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

Expand Down
2 changes: 1 addition & 1 deletion crates/service/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn serve_metrics(host_and_port: SocketAddr) {
tracing::error!("Error encoding metrics: {}", e);
(
StatusCode::INTERNAL_SERVER_ERROR,
format!("Error encoding metrics: {}", e),
format!("Error encoding metrics: {e}"),
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/service/src/middleware/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ mod tests {
let mut req = Request::new(Default::default());
req.headers_mut().insert(
header::AUTHORIZATION,
format!("Bearer {}", BEARER_TOKEN).parse().unwrap(),
format!("Bearer {BEARER_TOKEN}").parse().unwrap(),
);
let res = service.call(req).await.unwrap();
assert_eq!(res.status(), StatusCode::OK);
Expand Down
2 changes: 1 addition & 1 deletion crates/service/src/middleware/auth/bearer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl<ResBody> Bearer<ResBody> {
ResBody: Default,
{
Self {
header_value: format!("Bearer {}", token)
header_value: format!("Bearer {token}")
.parse()
.expect("token is not a valid header value"),
_ty: PhantomData,
Expand Down
2 changes: 1 addition & 1 deletion crates/service/src/middleware/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mod tests {
let res = app
.oneshot(
Request::builder()
.uri(format!("/{}", deployment))
.uri(format!("/{deployment}"))
.body(Body::empty())
.unwrap(),
)
Expand Down
2 changes: 1 addition & 1 deletion crates/service/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub async fn run() -> anyhow::Result<()> {
additional_networks,
} = dips;

let addr = format!("{}:{}", host, port)
let addr = format!("{host}:{port}")
.parse()
.expect("invalid dips host port");

Expand Down
2 changes: 1 addition & 1 deletion crates/service/src/tap/receipt_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl InnerContext {
}
Err(e) => {
// Create error message once
let err_msg = format!("Failed to store {} receipts: {}", version, e);
let err_msg = format!("Failed to store {version} receipts: {e}");
tracing::error!("{}", err_msg);
for sender in senders {
// Convert to AdapterError for each sender
Expand Down
4 changes: 2 additions & 2 deletions crates/tap-agent/src/agent/sender_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ impl Actor for SenderAccount {
.iter()
.map(|rav| rav.0.to_string())
.collect::<Vec<_>>(),
sender: format!("{:x?}", sender_id),
sender: format!("{sender_id:x?}"),
},
)
.await
Expand Down Expand Up @@ -882,7 +882,7 @@ impl Actor for SenderAccount {
))
})
.filter(|(allocation, _value)| {
!redeemed_ravs_allocation_ids.contains(&format!("{:x?}", allocation))
!redeemed_ravs_allocation_ids.contains(&format!("{allocation:x?}"))
})
.collect::<HashMap<_, _>>();

Expand Down
2 changes: 1 addition & 1 deletion crates/tap-agent/src/agent/sender_accounts_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ impl State {
SenderType::Legacy => "legacy:",
SenderType::Horizon => "horizon:",
});
sender_allocation_id.push_str(&format!("{}", sender));
sender_allocation_id.push_str(&format!("{sender}"));
sender_allocation_id
}

Expand Down
4 changes: 2 additions & 2 deletions crates/tap-agent/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async fn handler_metrics() -> (StatusCode, String) {
tracing::error!("Error encoding metrics: {}", e);
(
StatusCode::INTERNAL_SERVER_ERROR,
format!("Error encoding metrics: {}", e),
format!("Error encoding metrics: {e}"),
)
}
}
Expand All @@ -44,7 +44,7 @@ async fn _run_server(port: u16) {
tracing::debug!("Metrics server stopped");

if let Err(err) = res {
panic!("Metrics server error: {:#?}", err);
panic!("Metrics server error: {err:#?}");
};
}

Expand Down
2 changes: 1 addition & 1 deletion crates/tap-agent/src/tap/context/escrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl<T: NetworkVersion + Send + Sync> SignatureChecker for TapAgentContext<T> {
let sender = escrow_accounts
.get_sender_for_signer(&signer)
.map_err(|_| AdapterError::ValidationError {
error: format!("Could not find the sender for the signer {}", signer),
error: format!("Could not find the sender for the signer {signer}"),
})?;
Ok(sender == self.sender)
}
Expand Down
Loading
Loading