From 4574d4793adf26b079abd0ab7eb6140abebf72c6 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 28 Apr 2022 17:13:07 +0000 Subject: [PATCH] Migrate to 2021 edition --- Cargo.toml | 2 +- benches/note_decryption.rs | 4 +--- src/address.rs | 2 -- src/builder.rs | 1 - src/bundle.rs | 1 - src/circuit.rs | 7 ++----- src/circuit/commit_ivk.rs | 2 -- src/circuit/note_commit.rs | 1 - src/constants/load.rs | 2 -- src/keys.rs | 5 ++--- src/note/nullifier.rs | 1 - src/note_encryption.rs | 2 +- src/primitives/redpallas.rs | 3 --- src/spec.rs | 1 - src/tree.rs | 4 ---- src/value.rs | 1 - src/zip32.rs | 5 +---- tests/builder.rs | 2 -- 18 files changed, 8 insertions(+), 38 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dc26dcc2..e9a9accb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ authors = [ "Ying Tong Lai ", "Kris Nuttycombe ", ] -edition = "2018" +edition = "2021" rust-version = "1.56.1" description = "[BETA] The Orchard shielded transaction protocol" license-file = "LICENSE-BOSL" diff --git a/benches/note_decryption.rs b/benches/note_decryption.rs index 2e2975e5..94389c01 100644 --- a/benches/note_decryption.rs +++ b/benches/note_decryption.rs @@ -1,5 +1,3 @@ -use std::array; - use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; use orchard::{ builder::Builder, @@ -116,7 +114,7 @@ fn bench_note_decryption(c: &mut Criterion) { let mut group = c.benchmark_group("batch-note-decryption"); - for size in array::IntoIter::new([10, 50, 100]) { + for size in [10, 50, 100] { group.throughput(Throughput::Elements((ivks * size) as u64)); group.bench_function(BenchmarkId::new("valid", size), |b| { diff --git a/src/address.rs b/src/address.rs index 245021c6..67804e11 100644 --- a/src/address.rs +++ b/src/address.rs @@ -1,5 +1,3 @@ -use std::convert::TryInto; - use subtle::CtOption; use crate::{ diff --git a/src/builder.rs b/src/builder.rs index ae2df0ac..40aaf2e3 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -1,6 +1,5 @@ //! Logic for building Orchard components of transactions. -use std::convert::TryFrom; use std::fmt; use std::iter; diff --git a/src/bundle.rs b/src/bundle.rs index 73e9fc67..d701bd0e 100644 --- a/src/bundle.rs +++ b/src/bundle.rs @@ -2,7 +2,6 @@ pub mod commitments; -use std::convert::TryInto; use std::fmt; use std::io; diff --git a/src/circuit.rs b/src/circuit.rs index e613f787..4c9b36aa 100644 --- a/src/circuit.rs +++ b/src/circuit.rs @@ -52,8 +52,6 @@ use halo2_gadgets::{ utilities::{lookup_range_check::LookupRangeCheckConfig, UtilitiesInstructions}, }; -use std::convert::TryInto; - mod commit_ivk; pub mod gadget; mod note_commit; @@ -163,7 +161,7 @@ impl plonk::Circuit for Circuit { let not_enable_spends = one.clone() - meta.query_advice(advices[6], Rotation::cur()); let not_enable_outputs = one - meta.query_advice(advices[7], Rotation::cur()); - std::array::IntoIter::new([ + [ ( "v_old - v_new = magnitude * sign", v_old.clone() - v_new.clone() - magnitude * sign, @@ -177,7 +175,7 @@ impl plonk::Circuit for Circuit { "v_new = 0 or enable_outputs = 1", v_new * not_enable_outputs, ), - ]) + ] .map(move |(name, poly)| (name, q_orchard.clone() * poly)) }); @@ -1029,7 +1027,6 @@ mod tests { #[test] fn serialized_proof_test_case() { - use std::convert::TryInto; use std::io::{Read, Write}; let vk = VerifyingKey::build(); diff --git a/src/circuit/commit_ivk.rs b/src/circuit/commit_ivk.rs index 50a1f534..17b8a633 100644 --- a/src/circuit/commit_ivk.rs +++ b/src/circuit/commit_ivk.rs @@ -652,8 +652,6 @@ mod tests { use pasta_curves::{arithmetic::FieldExt, pallas}; use rand::rngs::OsRng; - use std::convert::TryInto; - #[test] fn commit_ivk() { #[derive(Default)] diff --git a/src/circuit/note_commit.rs b/src/circuit/note_commit.rs index de71f27d..3cf02100 100644 --- a/src/circuit/note_commit.rs +++ b/src/circuit/note_commit.rs @@ -1480,7 +1480,6 @@ mod tests { }; use rand::{rngs::OsRng, RngCore}; - use std::convert::TryInto; #[test] fn note_commit() { diff --git a/src/constants/load.rs b/src/constants/load.rs index 5368a962..e4edb359 100644 --- a/src/constants/load.rs +++ b/src/constants/load.rs @@ -1,5 +1,3 @@ -use std::convert::TryInto; - use crate::constants::{self, compute_lagrange_coeffs, H, NUM_WINDOWS, NUM_WINDOWS_SHORT}; use group::ff::PrimeField; use pasta_curves::pallas; diff --git a/src/keys.rs b/src/keys.rs index 9ba899d5..906f8620 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -1,7 +1,5 @@ //! Key structures for Orchard. -use std::array; -use std::convert::{TryFrom, TryInto}; use std::io::{self, Read, Write}; use std::mem; @@ -389,7 +387,8 @@ impl FullViewingKey { /// Returns the scope of the given address, or `None` if the address is not derived /// from this full viewing key. pub fn scope_for_address(&self, address: &Address) -> Option { - array::IntoIter::new([Scope::External, Scope::Internal]) + [Scope::External, Scope::Internal] + .into_iter() .find(|scope| self.to_ivk(*scope).diversifier_index(address).is_some()) } diff --git a/src/note/nullifier.rs b/src/note/nullifier.rs index 17b9d5c3..74efe5cd 100644 --- a/src/note/nullifier.rs +++ b/src/note/nullifier.rs @@ -66,7 +66,6 @@ pub mod testing { use pasta_curves::{arithmetic::FieldExt, pallas}; use proptest::collection::vec; use proptest::prelude::*; - use std::convert::TryFrom; use super::Nullifier; use crate::spec::extract_p; diff --git a/src/note_encryption.rs b/src/note_encryption.rs index a731cb0e..fcf99d33 100644 --- a/src/note_encryption.rs +++ b/src/note_encryption.rs @@ -1,6 +1,6 @@ //! In-band secret distribution for Orchard bundles. -use std::{convert::TryInto, fmt}; +use std::fmt; use blake2b_simd::{Hash, Params}; use group::ff::PrimeField; diff --git a/src/primitives/redpallas.rs b/src/primitives/redpallas.rs index 903de725..bd4d13eb 100644 --- a/src/primitives/redpallas.rs +++ b/src/primitives/redpallas.rs @@ -1,7 +1,6 @@ //! A minimal RedPallas implementation for use in Zcash. use std::cmp::{Ord, Ordering, PartialOrd}; -use std::convert::{TryFrom, TryInto}; use pasta_curves::pallas; use rand::{CryptoRng, RngCore}; @@ -184,8 +183,6 @@ pub(crate) mod private { #[cfg(any(test, feature = "test-dependencies"))] #[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))] pub mod testing { - use std::convert::TryFrom; - use proptest::prelude::*; use super::{Binding, SigningKey, SpendAuth, VerificationKey}; diff --git a/src/spec.rs b/src/spec.rs index 546fe6b4..4e1b97f1 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -276,7 +276,6 @@ mod tests { use halo2_proofs::arithmetic::CurveExt; use pasta_curves::pallas; use rand::{rngs::OsRng, RngCore}; - use std::convert::TryInto; #[test] fn diversify_hash_substitution() { diff --git a/src/tree.rs b/src/tree.rs index 824bf3fb..e512aaea 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -86,8 +86,6 @@ pub struct MerklePath { #[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))] impl From<(incrementalmerkletree::Position, Vec)> for MerklePath { fn from(path: (incrementalmerkletree::Position, Vec)) -> Self { - use std::convert::TryInto; - let position: u64 = path.0.into(); Self { position: position as u32, @@ -266,8 +264,6 @@ pub mod testing { use group::ff::PrimeField; #[cfg(test)] use pasta_curves::pallas; - #[cfg(test)] - use std::convert::TryInto; #[test] fn test_vectors() { diff --git a/src/value.rs b/src/value.rs index f4ebdeef..92a4dae8 100644 --- a/src/value.rs +++ b/src/value.rs @@ -35,7 +35,6 @@ //! [`Builder::add_recipient`]: crate::builder::Builder::add_recipient //! [Rust documentation]: https://doc.rust-lang.org/stable/std/primitive.i64.html -use std::convert::{TryFrom, TryInto}; use std::fmt::{self, Debug}; use std::iter::Sum; use std::ops::{Add, Sub}; diff --git a/src/zip32.rs b/src/zip32.rs index 31b9ef7c..020d9d71 100644 --- a/src/zip32.rs +++ b/src/zip32.rs @@ -1,9 +1,6 @@ //! Key structures for Orchard. -use std::{ - convert::{TryFrom, TryInto}, - fmt, -}; +use std::fmt; use blake2b_simd::Params as Blake2bParams; use subtle::{Choice, ConstantTimeEq}; diff --git a/tests/builder.rs b/tests/builder.rs index 9f89ec7d..ee1656f0 100644 --- a/tests/builder.rs +++ b/tests/builder.rs @@ -1,5 +1,3 @@ -use std::convert::TryInto; - use incrementalmerkletree::{bridgetree::BridgeTree, Frontier, Hashable, Tree}; use orchard::{ builder::Builder,