Skip to content

Commit dcbfbe5

Browse files
authored
Fix New Clippy Lints (#782)
This PR just fixes some clippy lints introduced in newer Rust versions. ### Test Plan CI
1 parent bee9014 commit dcbfbe5

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

ethcontract-common/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub use web3::types::Address;
1919
pub use web3::types::H256 as TransactionHash;
2020

2121
/// Information about when a contract instance was deployed
22-
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
22+
#[derive(Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize)]
2323
#[serde(untagged)]
2424
pub enum DeploymentInformation {
2525
/// The block at which the contract was deployed

ethcontract-generate/src/generate/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ fn expand_deployment_information(deployment: Option<DeploymentInformation>) -> T
231231
Some(ethcontract::common::DeploymentInformation::TransactionHash([#( #bytes ),*].into()))
232232
}
233233
}
234-
None => return quote! { None },
234+
None => quote! { None },
235235
}
236236
}
237237

ethcontract-mock/src/details/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ impl MockTransport {
114114

115115
pub fn checkpoint(&self) {
116116
let mut state = self.state.lock().unwrap();
117-
for contract in state.contracts.values_mut() {
117+
let contracts = state.contracts.values_mut();
118+
for contract in contracts {
118119
contract.checkpoint();
119120
}
120121
}

ethcontract-mock/src/test/returns.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async fn returns_default() -> Result {
1515

1616
let instance = AbiTypes::at(&contract.web3(), contract.address);
1717

18-
let _: () = instance.get_void().call().await?;
18+
instance.get_void().call().await?;
1919
assert_eq!(instance.get_u8().call().await?, 0);
2020
assert_eq!(instance.abiv_2_struct((1, 2)).call().await?, (0, 0));
2121
assert_eq!(
@@ -57,7 +57,7 @@ async fn returns_const() -> Result {
5757

5858
let instance = AbiTypes::at(&contract.web3(), contract.address);
5959

60-
let _: () = instance.get_void().call().await?;
60+
instance.get_void().call().await?;
6161
assert_eq!(instance.get_u8().call().await?, 42);
6262
assert_eq!(instance.abiv_2_struct((1, 2)).call().await?, (1, 2));
6363
assert_eq!(
@@ -101,7 +101,7 @@ async fn returns_fn() -> Result {
101101

102102
let instance = AbiTypes::at(&contract.web3(), contract.address);
103103

104-
let _: () = instance.get_void().call().await?;
104+
instance.get_void().call().await?;
105105
assert_eq!(instance.get_u8().call().await?, 42);
106106
assert_eq!(instance.abiv_2_struct((1, 2)).call().await?, (1, 2));
107107
assert_eq!(
@@ -145,7 +145,7 @@ async fn returns_fn_ctx() -> Result {
145145

146146
let instance = AbiTypes::at(&contract.web3(), contract.address);
147147

148-
let _: () = instance.get_void().call().await?;
148+
instance.get_void().call().await?;
149149
assert_eq!(instance.get_u8().call().await?, 42);
150150
assert_eq!(instance.abiv_2_struct((1, 2)).call().await?, (1, 2));
151151
assert_eq!(

ethcontract/src/int.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ impl I256 {
278278

279279
/// Convert from a decimal string.
280280
pub fn from_dec_str(value: &str) -> Result<Self, ParseI256Error> {
281-
let (sign, value) = match value.as_bytes().get(0) {
281+
let (sign, value) = match value.as_bytes().first() {
282282
Some(b'+') => (Sign::Positive, &value[1..]),
283283
Some(b'-') => (Sign::Negative, &value[1..]),
284284
_ => (Sign::Positive, value),
@@ -293,7 +293,7 @@ impl I256 {
293293

294294
/// Convert from a hexadecimal string.
295295
pub fn from_hex_str(value: &str) -> Result<Self, ParseI256Error> {
296-
let (sign, value) = match value.as_bytes().get(0) {
296+
let (sign, value) = match value.as_bytes().first() {
297297
Some(b'+') => (Sign::Positive, &value[1..]),
298298
Some(b'-') => (Sign::Negative, &value[1..]),
299299
_ => (Sign::Positive, value),

ethcontract/src/secret.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl PrivateKey {
4242
/// Gets the public address for a given private key.
4343
pub fn public_address(&self) -> Address {
4444
let secp = Secp256k1::signing_only();
45-
let public_key = PublicKey::from_secret_key(&secp, &*self).serialize_uncompressed();
45+
let public_key = PublicKey::from_secret_key(&secp, self).serialize_uncompressed();
4646

4747
// NOTE: An ethereum address is the last 20 bytes of the keccak hash of
4848
// the public key. Note that `libsecp256k1` public key is serialized

ethcontract/src/test/transport.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ impl Transport for TestTransport {
3636
}
3737

3838
fn send(&self, id: RequestId, request: Call) -> Self::Out {
39-
let mut inner = self.inner.lock().unwrap();
40-
match inner.responses.pop_front() {
39+
let response = self.inner.lock().unwrap().responses.pop_front();
40+
match response {
4141
Some(response) => future::ok(response),
4242
None => {
4343
println!("Unexpected request (id: {:?}): {:?}", id, request);

ethcontract/src/transaction/gas_price.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use primitive_types::U256;
44
use web3::types::U64;
55

6-
#[derive(Debug, Default, PartialEq)]
6+
#[derive(Debug, Default, Eq, PartialEq)]
77
/// Data related to gas price, prepared for populating the transaction object.
88
pub struct ResolvedTransactionGasPrice {
99
/// Legacy gas price, populated if transaction type is legacy
@@ -18,7 +18,7 @@ pub struct ResolvedTransactionGasPrice {
1818
}
1919

2020
/// The gas price setting to use.
21-
#[derive(Clone, Copy, Debug, PartialEq)]
21+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
2222
pub enum GasPrice {
2323
/// Legacy type of transactions, using single gas price value. Equivalent to sending
2424
/// eip1559 transaction with max_fee_per_gas = max_priority_fee_per_gas = gas_price

ethcontract/src/transport.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,7 @@ mod tests {
169169
dyn_transport
170170
.execute("test", vec![json!(42)])
171171
.immediate()
172-
.err()
173-
.expect("failed");
172+
.expect_err("failed");
174173
transport.assert_request("test", &[json!(42)]);
175174
transport.assert_no_more_requests();
176175
}

0 commit comments

Comments
 (0)