From 89b0403582e170ef9b16d14d524ac376e76ae0f6 Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Fri, 14 Jan 2022 07:10:18 -0500 Subject: [PATCH] Enforce Rust edition 2021 (#3332) * Rust edition 2021: zebra-network, cargo fix --edition and clippy --fix * Rust edition 2021: zebra-chain, cargo fix --edition * Rust edition 2021: tower-batch, cargo fix --edition * Rust edition 2021: tower-fallback, cargo fix --edition * Rust edition 2021: zebra-client, cargo fix --edition * Rust edition 2021: zebra-consensus, cargo fix --edition * Rust edition 2021: zebra-rpc, cargo fix --edition * Rust edition 2021: zebra-state, cargo fix --edition * Rust edition 2021: zebra-state, cargo fix --edition * Rust edition 2021: zebra-test, cargo fix --edition * Rust edition 2021: zebra-utils, cargo fix --edition * Rust edition 2021: zebrad, cargo fix --edition Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- tower-batch/Cargo.toml | 2 +- tower-batch/src/lib.rs | 1 + tower-fallback/Cargo.toml | 2 +- tower-fallback/src/lib.rs | 1 + zebra-chain/Cargo.toml | 2 +- zebra-chain/src/lib.rs | 1 + zebra-chain/src/primitives/redpallas/verification_key.rs | 3 +-- zebra-chain/src/value_balance.rs | 2 -- zebra-client/Cargo.toml | 2 +- zebra-client/src/lib.rs | 1 + zebra-consensus/Cargo.toml | 2 +- zebra-consensus/src/lib.rs | 5 ++--- zebra-network/Cargo.toml | 2 +- zebra-network/src/lib.rs | 1 + zebra-network/src/protocol/external/codec.rs | 2 +- zebra-rpc/Cargo.toml | 2 +- zebra-rpc/src/lib.rs | 1 + zebra-script/Cargo.toml | 2 +- zebra-script/src/lib.rs | 1 + zebra-state/Cargo.toml | 2 +- zebra-state/src/lib.rs | 1 + zebra-test/Cargo.toml | 2 +- zebra-test/src/lib.rs | 1 + zebra-utils/Cargo.toml | 2 +- zebra-utils/src/lib.rs | 1 + zebrad/Cargo.toml | 2 +- zebrad/src/lib.rs | 1 + 27 files changed, 27 insertions(+), 20 deletions(-) diff --git a/tower-batch/Cargo.toml b/tower-batch/Cargo.toml index 9a9fb9dae76..fb6c6474f6a 100644 --- a/tower-batch/Cargo.toml +++ b/tower-batch/Cargo.toml @@ -3,7 +3,7 @@ name = "tower-batch" version = "0.2.19" authors = ["Zcash Foundation "] license = "MIT" -edition = "2018" +edition = "2021" [dependencies] futures = "0.3.19" diff --git a/tower-batch/src/lib.rs b/tower-batch/src/lib.rs index edd8a4315bb..6a6e1b88792 100644 --- a/tower-batch/src/lib.rs +++ b/tower-batch/src/lib.rs @@ -89,6 +89,7 @@ #![warn(missing_docs)] #![allow(clippy::try_err)] #![deny(clippy::await_holding_lock)] +#![deny(rust_2021_compatibility)] #![forbid(unsafe_code)] pub mod error; diff --git a/tower-fallback/Cargo.toml b/tower-fallback/Cargo.toml index 5fd67c478d6..3c991daa2c7 100644 --- a/tower-fallback/Cargo.toml +++ b/tower-fallback/Cargo.toml @@ -3,7 +3,7 @@ name = "tower-fallback" version = "0.2.15" authors = ["Zcash Foundation "] license = "MIT" -edition = "2018" +edition = "2021" [dependencies] tower = "0.4" diff --git a/tower-fallback/src/lib.rs b/tower-fallback/src/lib.rs index cc73bac1543..2cb4d20eb8a 100644 --- a/tower-fallback/src/lib.rs +++ b/tower-fallback/src/lib.rs @@ -14,6 +14,7 @@ #![warn(missing_docs)] #![allow(clippy::try_err)] #![deny(clippy::await_holding_lock)] +#![deny(rust_2021_compatibility)] #![forbid(unsafe_code)] pub mod future; diff --git a/zebra-chain/Cargo.toml b/zebra-chain/Cargo.toml index b72df6fae9f..9b6a08cda3e 100644 --- a/zebra-chain/Cargo.toml +++ b/zebra-chain/Cargo.toml @@ -3,7 +3,7 @@ name = "zebra-chain" version = "1.0.0-beta.3" authors = ["Zcash Foundation "] license = "MIT OR Apache-2.0" -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/zebra-chain/src/lib.rs b/zebra-chain/src/lib.rs index 3bbbb42d2ad..79d6a0056a6 100644 --- a/zebra-chain/src/lib.rs +++ b/zebra-chain/src/lib.rs @@ -10,6 +10,7 @@ #![warn(missing_docs)] #![allow(clippy::try_err)] #![deny(clippy::await_holding_lock)] +#![deny(rust_2021_compatibility)] #![forbid(unsafe_code)] // Required by bitvec! macro #![recursion_limit = "256"] diff --git a/zebra-chain/src/primitives/redpallas/verification_key.rs b/zebra-chain/src/primitives/redpallas/verification_key.rs index d1ce26341cc..f8442712313 100644 --- a/zebra-chain/src/primitives/redpallas/verification_key.rs +++ b/zebra-chain/src/primitives/redpallas/verification_key.rs @@ -1,4 +1,4 @@ -use std::{convert::TryFrom, marker::PhantomData}; +use std::marker::PhantomData; use group::{cofactor::CofactorGroup, GroupEncoding}; use halo2::{arithmetic::FieldExt, pasta::pallas}; @@ -95,7 +95,6 @@ impl TryFrom<[u8; 32]> for VerificationKey { type Error = Error; fn try_from(bytes: [u8; 32]) -> Result { - use std::convert::TryInto; VerificationKeyBytes::from(bytes).try_into() } } diff --git a/zebra-chain/src/value_balance.rs b/zebra-chain/src/value_balance.rs index a2716422704..05d53a22637 100644 --- a/zebra-chain/src/value_balance.rs +++ b/zebra-chain/src/value_balance.rs @@ -311,8 +311,6 @@ impl ValueBalance { /// The resulting [`ValueBalance`] will have half of the MAX_MONEY amount on each pool. #[cfg(any(test, feature = "proptest-impl"))] pub fn fake_populated_pool() -> ValueBalance { - use std::convert::TryFrom; - let mut fake_value_pool = ValueBalance::zero(); let fake_transparent_value_balance = diff --git a/zebra-client/Cargo.toml b/zebra-client/Cargo.toml index 4b140fd8bfc..f942ba1c976 100644 --- a/zebra-client/Cargo.toml +++ b/zebra-client/Cargo.toml @@ -3,7 +3,7 @@ name = "zebra-client" version = "1.0.0-beta.0" authors = ["Zcash Foundation "] license = "MIT OR Apache-2.0" -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/zebra-client/src/lib.rs b/zebra-client/src/lib.rs index 8a8bd09d0cd..298924110ea 100644 --- a/zebra-client/src/lib.rs +++ b/zebra-client/src/lib.rs @@ -7,4 +7,5 @@ #![warn(missing_docs)] #![allow(clippy::try_err)] #![deny(clippy::await_holding_lock)] +#![deny(rust_2021_compatibility)] #![forbid(unsafe_code)] diff --git a/zebra-consensus/Cargo.toml b/zebra-consensus/Cargo.toml index 7ef66447e4b..4f4312588b7 100644 --- a/zebra-consensus/Cargo.toml +++ b/zebra-consensus/Cargo.toml @@ -3,7 +3,7 @@ name = "zebra-consensus" version = "1.0.0-beta.3" authors = ["Zcash Foundation "] license = "MIT OR Apache-2.0" -edition = "2018" +edition = "2021" [features] default = [] diff --git a/zebra-consensus/src/lib.rs b/zebra-consensus/src/lib.rs index bab7a166cd9..6d27f6787ea 100644 --- a/zebra-consensus/src/lib.rs +++ b/zebra-consensus/src/lib.rs @@ -38,6 +38,7 @@ #![warn(missing_docs)] #![allow(clippy::try_err)] #![deny(clippy::await_holding_lock)] +#![deny(rust_2021_compatibility)] #![forbid(unsafe_code)] mod block; @@ -54,9 +55,7 @@ pub mod chain; pub mod error; pub use block::VerifyBlockError; -pub use checkpoint::VerifyCheckpointError; -pub use checkpoint::MAX_CHECKPOINT_BYTE_COUNT; -pub use checkpoint::MAX_CHECKPOINT_HEIGHT_GAP; +pub use checkpoint::{VerifyCheckpointError, MAX_CHECKPOINT_BYTE_COUNT, MAX_CHECKPOINT_HEIGHT_GAP}; pub use config::Config; pub use error::BlockError; pub use primitives::groth16; diff --git a/zebra-network/Cargo.toml b/zebra-network/Cargo.toml index db1fab2f16a..3f70284e0f6 100644 --- a/zebra-network/Cargo.toml +++ b/zebra-network/Cargo.toml @@ -3,7 +3,7 @@ name = "zebra-network" version = "1.0.0-beta.3" authors = ["Zcash Foundation "] license = "MIT OR Apache-2.0" -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/zebra-network/src/lib.rs b/zebra-network/src/lib.rs index 82c8ceba11e..d98672518cc 100644 --- a/zebra-network/src/lib.rs +++ b/zebra-network/src/lib.rs @@ -37,6 +37,7 @@ #![warn(missing_docs)] #![allow(clippy::try_err)] #![deny(clippy::await_holding_lock)] +#![deny(rust_2021_compatibility)] #![forbid(unsafe_code)] #[macro_use] diff --git a/zebra-network/src/protocol/external/codec.rs b/zebra-network/src/protocol/external/codec.rs index f1c53829d84..36e0a97187f 100644 --- a/zebra-network/src/protocol/external/codec.rs +++ b/zebra-network/src/protocol/external/codec.rs @@ -184,7 +184,7 @@ impl Codec { /// for large data structures like lists, blocks, and transactions. /// See #1774. fn body_length(&self, msg: &Message) -> usize { - let mut writer = FakeWriter { 0: 0 }; + let mut writer = FakeWriter(0); self.write_body(msg, &mut writer) .expect("writer should never fail"); diff --git a/zebra-rpc/Cargo.toml b/zebra-rpc/Cargo.toml index 1f599051f39..e866af9a512 100644 --- a/zebra-rpc/Cargo.toml +++ b/zebra-rpc/Cargo.toml @@ -3,7 +3,7 @@ name = "zebra-rpc" version = "1.0.0-beta.0" authors = ["Zcash Foundation "] license = "MIT OR Apache-2.0" -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/zebra-rpc/src/lib.rs b/zebra-rpc/src/lib.rs index a8e35df40a4..02f87917a0d 100644 --- a/zebra-rpc/src/lib.rs +++ b/zebra-rpc/src/lib.rs @@ -7,4 +7,5 @@ #![warn(missing_docs)] #![allow(clippy::try_err)] #![deny(clippy::await_holding_lock)] +#![deny(rust_2021_compatibility)] #![forbid(unsafe_code)] diff --git a/zebra-script/Cargo.toml b/zebra-script/Cargo.toml index 1dedcc30848..cf83c01ddd3 100644 --- a/zebra-script/Cargo.toml +++ b/zebra-script/Cargo.toml @@ -3,7 +3,7 @@ name = "zebra-script" version = "1.0.0-beta.3" authors = ["Zcash Foundation "] license = "MIT OR Apache-2.0" -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/zebra-script/src/lib.rs b/zebra-script/src/lib.rs index 0e556fb6eae..effdda7d277 100644 --- a/zebra-script/src/lib.rs +++ b/zebra-script/src/lib.rs @@ -6,6 +6,7 @@ #![warn(missing_docs)] #![allow(clippy::try_err)] #![deny(clippy::await_holding_lock)] +#![deny(rust_2021_compatibility)] // we allow unsafe code, so we can call zcash_script use std::{convert::TryInto, sync::Arc}; diff --git a/zebra-state/Cargo.toml b/zebra-state/Cargo.toml index 4290312c54e..92a969dddfa 100644 --- a/zebra-state/Cargo.toml +++ b/zebra-state/Cargo.toml @@ -3,7 +3,7 @@ name = "zebra-state" version = "1.0.0-beta.3" authors = ["Zcash Foundation "] license = "MIT OR Apache-2.0" -edition = "2018" +edition = "2021" [features] proptest-impl = ["proptest", "proptest-derive", "zebra-test"] diff --git a/zebra-state/src/lib.rs b/zebra-state/src/lib.rs index 3621509ff61..c01a633f7ef 100644 --- a/zebra-state/src/lib.rs +++ b/zebra-state/src/lib.rs @@ -15,6 +15,7 @@ #![warn(missing_docs)] #![allow(clippy::try_err)] #![deny(clippy::await_holding_lock)] +#![deny(rust_2021_compatibility)] #![forbid(unsafe_code)] #[cfg(any(test, feature = "proptest-impl"))] diff --git a/zebra-test/Cargo.toml b/zebra-test/Cargo.toml index 3278bf2b90f..fa21aefac43 100644 --- a/zebra-test/Cargo.toml +++ b/zebra-test/Cargo.toml @@ -3,7 +3,7 @@ name = "zebra-test" version = "1.0.0-beta.3" authors = ["Zcash Foundation "] license = "MIT OR Apache-2.0" -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/zebra-test/src/lib.rs b/zebra-test/src/lib.rs index fb9d0f050a5..b1c30d03e52 100644 --- a/zebra-test/src/lib.rs +++ b/zebra-test/src/lib.rs @@ -6,6 +6,7 @@ #![warn(missing_docs)] #![allow(clippy::try_err)] #![deny(clippy::await_holding_lock)] +#![deny(rust_2021_compatibility)] #![forbid(unsafe_code)] // Each lazy_static variable uses additional recursion #![recursion_limit = "512"] diff --git a/zebra-utils/Cargo.toml b/zebra-utils/Cargo.toml index e63426cd0ab..3a472f738ce 100644 --- a/zebra-utils/Cargo.toml +++ b/zebra-utils/Cargo.toml @@ -3,7 +3,7 @@ name = "zebra-utils" authors = ["Zcash Foundation "] license = "MIT OR Apache-2.0" version = "1.0.0-beta.3" -edition = "2018" +edition = "2021" # Prevent accidental publication of this utility crate. publish = false diff --git a/zebra-utils/src/lib.rs b/zebra-utils/src/lib.rs index 9d0c1a42a67..d619fb0df66 100644 --- a/zebra-utils/src/lib.rs +++ b/zebra-utils/src/lib.rs @@ -8,4 +8,5 @@ #![warn(missing_docs)] #![allow(clippy::try_err)] #![deny(clippy::await_holding_lock)] +#![deny(rust_2021_compatibility)] #![forbid(unsafe_code)] diff --git a/zebrad/Cargo.toml b/zebrad/Cargo.toml index 6c47f503915..35e4ba7ee8e 100644 --- a/zebrad/Cargo.toml +++ b/zebrad/Cargo.toml @@ -3,7 +3,7 @@ name = "zebrad" authors = ["Zcash Foundation "] license = "MIT OR Apache-2.0" version = "1.0.0-beta.3" -edition = "2018" +edition = "2021" repository = "https://github.com/ZcashFoundation/zebra" # make `cargo run` use `zebrad` by default # when run in the workspace directory diff --git a/zebrad/src/lib.rs b/zebrad/src/lib.rs index ab9ec41b8d4..cfa4ac629ca 100644 --- a/zebrad/src/lib.rs +++ b/zebrad/src/lib.rs @@ -21,6 +21,7 @@ #![warn(missing_docs)] #![allow(clippy::try_err)] #![deny(clippy::await_holding_lock)] +#![deny(rust_2021_compatibility)] #![forbid(unsafe_code)] // Tracing causes false positives on this lint: // https://github.com/tokio-rs/tracing/issues/553