Repository: gakonst/ethers-rs
Pull request #1541 (2022-08-01 00:38:38)

ci: rm pinned nightly
<!--
Thank you for your Pull Request. Please provide a description above and review
the requirements below.

Bug fixes and new features should include tests.

Contributors guide: https://github.com/gakonst/ethers-rs/blob/master/CONTRIBUTING.md

The contributors guide includes instructions for running rustfmt and building the
documentation.
-->

## Motivation
remove pinned nightly for lint job that was added due to a regression 72dfc52ec041f4368a00aa9a27305f777ec710d8
<!--
Explain the context and why you're making that change. What is the problem
you're trying to solve? In some cases there is not a problem and this can be
thought of as being the motivation for your change.
-->

## Solution

fix clippy lints: `cargo +nightly clippy --fix -Z unstable-options`

<!--
Summarize the solution and provide any necessary context needed to understand
the code change.
-->

## PR Checklist

- [ ] Added Tests
- [ ] Added Documentation
- [ ] Updated the changelog



Patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 65c0c23e..17323a3e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -111,8 +111,7 @@ jobs:
       - name: Install toolchain
         uses: actions-rs/toolchain@v1
         with:
-          # nightly regression https://github.com/rust-lang/rust/issues/95267
-          toolchain: nightly-2022-03-20
+          toolchain: nightly
           profile: minimal
           components: rustfmt, clippy
           override: true
@@ -120,9 +119,9 @@ jobs:
         with:
           cache-on-failure: true
       - name: cargo fmt
-        run: cargo +nightly-2022-03-20 fmt --all -- --check
+        run: cargo +nightly fmt --all -- --check
       - name: cargo clippy
-        run: cargo +nightly-2022-03-20 clippy --all-features -- -D warnings
+        run: cargo +nightly clippy --all-features -- -D warnings
 
   wasm:
     name: WASM
diff --git a/ethers-contract/ethers-contract-abigen/src/contract/structs.rs b/ethers-contract/ethers-contract-abigen/src/contract/structs.rs
index c1a51ded..947604b9 100644
--- a/ethers-contract/ethers-contract-abigen/src/contract/structs.rs
+++ b/ethers-contract/ethers-contract-abigen/src/contract/structs.rs
@@ -543,11 +543,11 @@ fn expand_struct_type(struct_ty: &StructFieldType) -> TokenStream {
             quote! {#ty}
         }
         StructFieldType::Array(ty) => {
-            let ty = expand_struct_type(&*ty);
+            let ty = expand_struct_type(ty);
             quote! {::std::vec::Vec<#ty>}
         }
         StructFieldType::FixedArray(ty, size) => {
-            let ty = expand_struct_type(&*ty);
+            let ty = expand_struct_type(ty);
             quote! { [#ty; #size]}
         }
     }
diff --git a/ethers-contract/ethers-contract-abigen/src/multi.rs b/ethers-contract/ethers-contract-abigen/src/multi.rs
index 6266abcc..37c8ab76 100644
--- a/ethers-contract/ethers-contract-abigen/src/multi.rs
+++ b/ethers-contract/ethers-contract-abigen/src/multi.rs
@@ -782,7 +782,7 @@ mod tests {
 
         let result = panic::catch_unwind(|| test(&context));
 
-        assert!(result.is_ok())
+        result.unwrap()
     }
 
     #[test]
diff --git a/ethers-contract/ethers-contract-abigen/src/rawabi.rs b/ethers-contract/ethers-contract-abigen/src/rawabi.rs
index 086bec4c..c25618f7 100644
--- a/ethers-contract/ethers-contract-abigen/src/rawabi.rs
+++ b/ethers-contract/ethers-contract-abigen/src/rawabi.rs
@@ -207,7 +207,7 @@ mod tests {
     use ethers_core::abi::Abi;
 
     fn assert_has_bytecode(s: &str) {
-        match serde_json::from_str::<JsonAbi>(&s).unwrap() {
+        match serde_json::from_str::<JsonAbi>(s).unwrap() {
             JsonAbi::Object(abi) => {
                 assert!(abi.bytecode.is_some());
             }
diff --git a/ethers-contract/ethers-contract-abigen/src/util.rs b/ethers-contract/ethers-contract-abigen/src/util.rs
index 33936e09..ec465104 100644
--- a/ethers-contract/ethers-contract-abigen/src/util.rs
+++ b/ethers-contract/ethers-contract-abigen/src/util.rs
@@ -214,18 +214,12 @@ mod tests {
 
     #[test]
     fn parse_address_missing_prefix() {
-        assert!(
-            parse_address("0000000000000000000000000000000000000000").is_err(),
-            "parsing address not starting with 0x should fail"
-        );
+        let _ = parse_address("0000000000000000000000000000000000000000").unwrap_err();
     }
 
     #[test]
     fn parse_address_address_too_short() {
-        assert!(
-            parse_address("0x00000000000000").is_err(),
-            "parsing address not starting with 0x should fail"
-        );
+        let _ = parse_address("0x00000000000000").unwrap_err();
     }
 
     #[test]
diff --git a/ethers-contract/ethers-contract-derive/src/utils.rs b/ethers-contract/ethers-contract-derive/src/utils.rs
index abef0999..65319f06 100644
--- a/ethers-contract/ethers-contract-derive/src/utils.rs
+++ b/ethers-contract/ethers-contract-derive/src/utils.rs
@@ -70,7 +70,7 @@ pub fn param_type_quote(kind: &ParamType) -> proc_macro2::TokenStream {
             quote! {#core_crate::abi::ParamType::String}
         }
         ParamType::Array(ty) => {
-            let ty = param_type_quote(&*ty);
+            let ty = param_type_quote(ty);
             quote! {#core_crate::abi::ParamType::Array(Box::new(#ty))}
         }
         ParamType::FixedBytes(size) => {
@@ -78,7 +78,7 @@ pub fn param_type_quote(kind: &ParamType) -> proc_macro2::TokenStream {
             quote! {#core_crate::abi::ParamType::FixedBytes(#size)}
         }
         ParamType::FixedArray(ty, size) => {
-            let ty = param_type_quote(&*ty);
+            let ty = param_type_quote(ty);
             let size = Literal::usize_suffixed(*size);
             quote! {#core_crate::abi::ParamType::FixedArray(Box::new(#ty),#size)}
         }
diff --git a/ethers-core/src/abi/struct_def.rs b/ethers-core/src/abi/struct_def.rs
index 3a77bb7e..ff8945a0 100644
--- a/ethers-core/src/abi/struct_def.rs
+++ b/ethers-core/src/abi/struct_def.rs
@@ -509,7 +509,7 @@ mod tests {
         ]
         .iter()
         .for_each(|s| {
-            assert!(parse_mapping(s).is_err());
+            parse_mapping(s).unwrap_err();
         });
     }
 
diff --git a/ethers-core/src/types/i256.rs b/ethers-core/src/types/i256.rs
index 48d8a28d..6b00105b 100644
--- a/ethers-core/src/types/i256.rs
+++ b/ethers-core/src/types/i256.rs
@@ -1382,9 +1382,9 @@ mod tests {
 
         assert_eq!(I256::try_from(large_unsigned).unwrap(), large_positive);
         assert_eq!(U256::try_from(large_positive).unwrap(), large_unsigned);
-        assert!(I256::try_from(U256::MAX).is_err());
-        assert!(U256::try_from(small_negative).is_err());
-        assert!(U256::try_from(large_negative).is_err());
+        I256::try_from(U256::MAX).unwrap_err();
+        U256::try_from(small_negative).unwrap_err();
+        U256::try_from(large_negative).unwrap_err();
     }
 
     #[test]
diff --git a/ethers-etherscan/src/account.rs b/ethers-etherscan/src/account.rs
index a33f4484..8893a2c1 100644
--- a/ethers-etherscan/src/account.rs
+++ b/ethers-etherscan/src/account.rs
@@ -681,7 +681,7 @@ mod tests {
                     None,
                 )
                 .await;
-            assert!(balance.is_ok());
+            balance.unwrap();
         })
         .await
     }
@@ -717,7 +717,7 @@ mod tests {
                     None,
                 )
                 .await;
-            assert!(txs.is_ok());
+            txs.unwrap();
         })
         .await
     }
@@ -736,7 +736,7 @@ mod tests {
                     None,
                 )
                 .await;
-            assert!(txs.is_ok());
+            txs.unwrap();
         })
         .await
     }
@@ -757,7 +757,7 @@ mod tests {
                     None,
                 )
                 .await;
-            assert!(txs.is_ok());
+            txs.unwrap();
         })
         .await
     }
@@ -800,7 +800,7 @@ mod tests {
                     None,
                 )
                 .await;
-            assert!(txs.is_ok());
+            txs.unwrap();
         })
         .await
     }
@@ -820,7 +820,7 @@ mod tests {
                     None,
                 )
                 .await;
-            assert!(txs.is_ok());
+            txs.unwrap();
         })
         .await
     }
@@ -838,7 +838,7 @@ mod tests {
                     None,
                 )
                 .await;
-            assert!(blocks.is_ok());
+            blocks.unwrap();
         })
         .await
     }
@@ -854,6 +854,6 @@ mod tests {
         let txs = client
             .get_transactions(&"0x1549ea9b546ba9ffb306d78a1e1f304760cc4abf".parse().unwrap(), None)
             .await;
-        assert!(txs.is_ok());
+        txs.unwrap();
     }
 }
diff --git a/ethers-etherscan/src/gas.rs b/ethers-etherscan/src/gas.rs
index 94e93b1e..988a3285 100644
--- a/ethers-etherscan/src/gas.rs
+++ b/ethers-etherscan/src/gas.rs
@@ -84,7 +84,7 @@ mod tests {
 
             let result = client.gas_estimate(2000000000u32.into()).await;
 
-            assert!(result.is_ok());
+            result.unwrap();
         })
         .await
     }
diff --git a/ethers-etherscan/src/transaction.rs b/ethers-etherscan/src/transaction.rs
index 9259b097..39b1cc3a 100644
--- a/ethers-etherscan/src/transaction.rs
+++ b/ethers-etherscan/src/transaction.rs
@@ -69,7 +69,7 @@ mod tests {
                 )
                 .await;
 
-            assert!(status.is_ok());
+            status.unwrap();
         })
         .await
     }
@@ -105,7 +105,7 @@ mod tests {
                 )
                 .await;
 
-            assert!(success.is_ok());
+            success.unwrap();
         })
         .await
     }
diff --git a/ethers-middleware/src/signer.rs b/ethers-middleware/src/signer.rs
index 33cd92ff..e38ed7e1 100644
--- a/ethers-middleware/src/signer.rs
+++ b/ethers-middleware/src/signer.rs
@@ -414,7 +414,7 @@ mod tests {
         let tx = client.sign_transaction(tx).await.unwrap();
 
         let expected_rlp = Bytes::from(hex::decode("f86b808504e3b29200831e848094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080820a95a08290324bae25ca0490077e0d1f4098730333088f6a500793fa420243f35c6b23a06aca42876cd28fdf614a4641e64222fee586391bb3f4061ed5dfefac006be850").unwrap());
-        assert_eq!(tx.clone(), expected_rlp);
+        assert_eq!(tx, expected_rlp);
     }
 
     #[tokio::test]
diff --git a/ethers-providers/src/transports/ws.rs b/ethers-providers/src/transports/ws.rs
index eebbccda..098a2d87 100644
--- a/ethers-providers/src/transports/ws.rs
+++ b/ethers-providers/src/transports/ws.rs
@@ -529,6 +529,6 @@ mod tests {
         let malformed_data = String::from("not a valid message");
         let (_, stream) = mpsc::unbounded();
         let resp = WsServer::new(ws, stream).handle_text(malformed_data).await;
-        assert!(resp.is_err(), "Deserialization should not fail silently");
+        resp.unwrap_err();
     }
 }
diff --git a/ethers-signers/src/wallet/private_key.rs b/ethers-signers/src/wallet/private_key.rs
index 8003fa31..10f0e9b7 100644
--- a/ethers-signers/src/wallet/private_key.rs
+++ b/ethers-signers/src/wallet/private_key.rs
@@ -166,7 +166,7 @@ mod tests {
         let key2 = Wallet::<SigningKey>::decrypt_keystore(&path.clone(), "randpsswd").unwrap();
         let signature2 = key2.sign_message(message).await.unwrap();
         assert_eq!(signature, signature2);
-        assert!(std::fs::remove_file(&path).is_ok());
+        std::fs::remove_file(&path).unwrap();
     }
 
     #[tokio::test]
@@ -216,7 +216,7 @@ mod tests {
 
         let sig = wallet.sign_transaction(&tx).await.unwrap();
         let sighash = tx.sighash();
-        assert!(sig.verify(sighash, wallet.address).is_ok());
+        sig.verify(sighash, wallet.address).unwrap();
     }
 
     #[tokio::test]
@@ -249,7 +249,7 @@ mod tests {
         let mut tx = tx;
         tx.set_chain_id(1);
         let sighash = tx.sighash();
-        assert!(sig.verify(sighash, wallet.address).is_ok());
+        sig.verify(sighash, wallet.address).unwrap();
     }
 
     #[test]
@@ -290,7 +290,7 @@ mod tests {
         let mut tx = tx;
         tx.set_chain_id(chain_id);
         let sighash = tx.sighash();
-        assert!(sig.verify(sighash, wallet.address).is_ok());
+        sig.verify(sighash, wallet.address).unwrap();
     }
 
     #[test]
diff --git a/ethers-solc/src/cache.rs b/ethers-solc/src/cache.rs
index 4e837bda..06657c9c 100644
--- a/ethers-solc/src/cache.rs
+++ b/ethers-solc/src/cache.rs
@@ -528,7 +528,7 @@ impl CacheEntry {
         &'a self,
         version: &'a Version,
     ) -> impl Iterator<Item = &'a PathBuf> + 'a {
-        self.artifacts_versions().filter_map(move |(ver, file)| (ver == version).then(|| file))
+        self.artifacts_versions().filter_map(move |(ver, file)| (ver == version).then_some(file))
     }
 
     /// Iterator that yields all artifact files
diff --git a/ethers-solc/src/filter.rs b/ethers-solc/src/filter.rs
index 0e1d2056..42cce5ff 100644
--- a/ethers-solc/src/filter.rs
+++ b/ethers-solc/src/filter.rs
@@ -221,7 +221,7 @@ impl FilteredSources {
 
     /// Returns all dirty files
     pub fn dirty_files(&self) -> impl Iterator<Item = &PathBuf> + fmt::Debug + '_ {
-        self.0.iter().filter_map(|(k, s)| s.is_dirty().then(|| k))
+        self.0.iter().filter_map(|(k, s)| s.is_dirty().then_some(k))
     }
 }
 


Test patch:
diff --git a/ethers-contract/tests/it/common/mod.rs b/ethers-contract/tests/it/common/mod.rs
index 3ec3e318..7ed4be56 100644
--- a/ethers-contract/tests/it/common/mod.rs
+++ b/ethers-contract/tests/it/common/mod.rs
@@ -52,6 +52,6 @@ pub fn connect(anvil: &AnvilInstance, idx: usize) -> Arc<Provider<Http>> {
 pub async fn deploy<M: Middleware>(client: Arc<M>, abi: Abi, bytecode: Bytes) -> Contract<M> {
     let factory = ContractFactory::new(abi, bytecode, client);
     let deployer = factory.deploy("initial value".to_string()).unwrap();
-    assert!(deployer.call().await.is_ok());
+    deployer.call().await.unwrap();
     deployer.legacy().send().await.unwrap()
 }
diff --git a/ethers-contract/tests/it/contract.rs b/ethers-contract/tests/it/contract.rs
index f40c76b1..6a593c5c 100644
--- a/ethers-contract/tests/it/contract.rs
+++ b/ethers-contract/tests/it/contract.rs
@@ -41,7 +41,7 @@ mod eth_tests {
         let deployer = factory.deploy("initial value".to_string()).unwrap().legacy();
         // dry runs the deployment of the contract. takes the deployer by reference, no need to
         // clone.
-        assert!(deployer.call().await.is_ok());
+        deployer.call().await.unwrap();
         let (contract, receipt) = deployer.clone().send_with_receipt().await.unwrap();
         assert_eq!(receipt.contract_address.unwrap(), contract.address());
 
diff --git a/ethers-middleware/tests/gas_oracle.rs b/ethers-middleware/tests/gas_oracle.rs
index 4e4270e8..10db9ba0 100644
--- a/ethers-middleware/tests/gas_oracle.rs
+++ b/ethers-middleware/tests/gas_oracle.rs
@@ -59,7 +59,7 @@ async fn eth_gas_station() {
     // initialize and fetch gas estimates from EthGasStation
     let eth_gas_station_oracle = EthGasStation::default();
     let data = eth_gas_station_oracle.fetch().await;
-    assert!(data.is_ok());
+    data.unwrap();
 }
 
 #[tokio::test]
@@ -71,13 +71,13 @@ async fn etherscan() {
     // since etherscan does not support `fastest` category, we expect an error
     let etherscan_oracle = Etherscan::new(etherscan_client.clone()).category(GasCategory::Fastest);
     let data = etherscan_oracle.fetch().await;
-    assert!(data.is_err());
+    data.unwrap_err();
 
     // but fetching the `standard` gas price should work fine
     let etherscan_oracle = Etherscan::new(etherscan_client).category(GasCategory::SafeLow);
 
     let data = etherscan_oracle.fetch().await;
-    assert!(data.is_ok());
+    data.unwrap();
 }
 
 #[tokio::test]
@@ -85,5 +85,5 @@ async fn etherchain() {
     // initialize and fetch gas estimates from Etherchain
     let etherchain_oracle = Etherchain::default().category(GasCategory::Fast);
     let data = etherchain_oracle.fetch().await;
-    assert!(data.is_ok());
+    data.unwrap();
 }