chore(clippy): make clippy happy (#1923)

This commit is contained in:
Matthias Seitz 2022-12-06 07:05:33 +01:00 committed by GitHub
parent 556821f077
commit 3dfc04f9fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 20 additions and 32 deletions

View File

@ -586,7 +586,7 @@ impl MultiBindingsInner {
writeln!(toml, "# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html")?;
writeln!(toml)?;
writeln!(toml, "[dependencies]")?;
writeln!(toml, r#"{}"#, crate_version)?;
writeln!(toml, r#"{crate_version}"#)?;
Ok(toml)
}
@ -619,11 +619,10 @@ impl MultiBindingsInner {
.ok_or_else(|| eyre::eyre!("couldn't find ethers or ethers-contract dependency"))?;
if let Some(rev) = ethers.get("rev") {
Ok(format!("ethers = {{ git = \"https://github.com/gakonst/ethers-rs\", rev = {}, default-features = false, features = [\"abigen\"] }}", rev))
Ok(format!("ethers = {{ git = \"https://github.com/gakonst/ethers-rs\", rev = {rev}, default-features = false, features = [\"abigen\"] }}"))
} else if let Some(version) = ethers.get("version") {
Ok(format!(
"ethers = {{ version = {}, default-features = false, features = [\"abigen\"] }}",
version
"ethers = {{ version = {version}, default-features = false, features = [\"abigen\"] }}"
))
} else {
Ok(DEFAULT_ETHERS_DEP.to_string())

View File

@ -270,8 +270,7 @@ fn get_etherscan_contract(address: Address, domain: &str) -> Result<String> {
};
let abi_url = format!(
"http://api.{}/api?module=contract&action=getabi&address={:?}&format=raw{}",
domain, address, api_key,
"http://api.{domain}/api?module=contract&action=getabi&address={address:?}&format=raw{api_key}",
);
let abi = util::http_get(&abi_url).context(format!("failed to retrieve ABI from {domain}"))?;

View File

@ -464,8 +464,7 @@ fn parse_event_attributes(
return Err(Error::new(
meta.span(),
format!(
"Expected hex signature: {:?}",
err
"Expected hex signature: {err:?}"
),
)
.to_compile_error())

View File

@ -59,8 +59,7 @@ impl Serialize for NameOrAddress {
match self {
Self::Address(addr) => addr.serialize(serializer),
Self::Name(name) => Err(SerializationError::custom(format!(
"cannot serialize ENS name {}, must be address",
name
"cannot serialize ENS name {name}, must be address"
))),
}
}

View File

@ -91,7 +91,7 @@ impl Serialize for TxpoolInspectSummary {
S: serde::Serializer,
{
let formatted_to = if let Some(to) = self.to {
format!("{:?}", to)
format!("{to:?}")
} else {
"contract creation".to_string()
};

View File

@ -1303,8 +1303,7 @@ impl<P: JsonRpcClient> Provider<P> {
if data.is_empty() {
return Err(ProviderError::EnsError(format!(
"`{}` resolver ({:?}) is invalid.",
ens_name, resolver_address
"`{ens_name}` resolver ({resolver_address:?}) is invalid."
)))
}
@ -2234,7 +2233,7 @@ mod tests {
}
.spawn();
let url = format!("http://127.0.0.1:{}", rpc_port);
let url = format!("http://127.0.0.1:{rpc_port}");
let provider = Provider::try_from(url).unwrap();
(geth, provider)
}

View File

@ -1,5 +1,5 @@
#![cfg(not(target_arch = "wasm32"))]
use ethers_providers::{Middleware, Provider, StreamExt};
#![allow(unused)]
use ethers_providers::{Middleware, Provider, StreamExt, Ws};
use futures_util::SinkExt;
use std::time::Duration;
use tokio::net::{TcpListener, TcpStream};
@ -17,11 +17,9 @@ const WS_ENDPOINT: &str = "127.0.0.1:9002";
#[cfg(not(feature = "celo"))]
mod eth_tests {
use ethers_core::types::Filter;
use ethers_providers::{StreamExt, Ws};
use tokio_tungstenite::connect_async;
use super::*;
use ethers_core::types::Filter;
use tokio_tungstenite::connect_async;
#[tokio::test]
async fn graceful_disconnect_on_ws_errors() {

View File

@ -532,8 +532,7 @@ impl Libraries {
.ok_or_else(|| SolcError::msg(format!("failed to parse library address: {lib}")))?;
if items.next().is_some() {
return Err(SolcError::msg(format!(
"failed to parse, too many arguments passed: {}",
lib
"failed to parse, too many arguments passed: {lib}"
)))
}
libraries

View File

@ -475,10 +475,9 @@ contract {} {{}}
format!(
r#"
// SPDX-License-Identifier: UNLICENSED
pragma solidity {};
{}
pragma solidity {version};
{imports}
"#,
version, imports,
)
}
}

View File

@ -587,8 +587,7 @@ impl Graph {
let mut msg = String::new();
self.format_imports_list(idx, &mut msg).unwrap();
errors.push(format!(
"Discovered incompatible solidity versions in following\n: {}",
msg
"Discovered incompatible solidity versions in following\n: {msg}"
));
erroneous_nodes.insert(idx);
} else {
@ -777,8 +776,7 @@ impl VersionedSources {
let solc = if !version.is_installed() {
if self.offline {
return Err(SolcError::msg(format!(
"missing solc \"{}\" installation in offline mode",
version
"missing solc \"{version}\" installation in offline mode"
)))
} else {
// install missing solc

View File

@ -1709,10 +1709,9 @@ async fn can_install_solc_and_compile_version() {
"Contract",
format!(
r#"
pragma solidity {};
pragma solidity {version};
contract Contract {{ }}
"#,
version
"#
),
)
.unwrap();