Skip to content

Commit

Permalink
Merge pull request #2405 from AleoHQ/bump/msrv-176
Browse files Browse the repository at this point in the history
Bumps MSRV to 1.76.0 and updates Clippy
  • Loading branch information
howardwu committed Mar 22, 2024
2 parents b028362 + 22e5db6 commit 78d449b
Show file tree
Hide file tree
Showing 20 changed files with 98 additions and 101 deletions.
144 changes: 72 additions & 72 deletions .circleci/config.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -22,7 +22,7 @@ categories = [
include = [ "Cargo.toml", "vm", "README.md", "LICENSE.md" ]
license = "Apache-2.0"
edition = "2021"
rust-version = "1.72.1"
rust-version = "1.76.0" # Attention - Change the MSRV in rust-toolchain and in .circleci/config.yml as well

[workspace]
members = [
Expand Down
1 change: 1 addition & 0 deletions algorithms/src/msm/variable_base/batched.rs
Expand Up @@ -43,6 +43,7 @@ impl Ord for BucketPosition {
}

impl PartialOrd for BucketPosition {
#[allow(clippy::non_canonical_partial_ord_impl)]
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
self.bucket_index.partial_cmp(&other.bucket_index)
}
Expand Down
Expand Up @@ -153,9 +153,7 @@ impl<F: PrimeField, SM: SNARKMode> AHPForR1CS<F, SM> {
let fft_precomputation = &circuit.fft_precomputation;
let ifft_precomputation = &circuit.ifft_precomputation;

for (_j, (&instance_combiner, assignment)) in
itertools::izip!(instance_combiners, assignments_i).enumerate()
{
for (&instance_combiner, assignment) in itertools::izip!(instance_combiners, assignments_i) {
for (label, matrix_combiner) in itertools::izip!(matrix_labels, matrix_combiners) {
let matrix_transpose = &matrix_transposes_i[label];
let combiner = circuit_combiner * instance_combiner * matrix_combiner;
Expand Down
4 changes: 2 additions & 2 deletions circuit/environment/src/traits/eject.rs
Expand Up @@ -69,7 +69,7 @@ impl Eject for Vec<Mode> {
fn eject_mode(&self) -> Mode {
// TODO (howardwu): Determine if a default mode of `constant` is appropriate.
// Retrieve the mode of the first circuit.
match self.get(0) {
match self.first() {
Some(first) => Mode::combine(*first, self.iter().copied().skip(1)),
// None => Mode::Constant,
None => panic!("Attempted to eject the mode on an empty circuit"),
Expand Down Expand Up @@ -123,7 +123,7 @@ impl<C: Eject<Primitive = P>, P> Eject for &[C] {
fn eject_mode(&self) -> Mode {
// TODO (howardwu): Determine if a default mode of `constant` is appropriate.
// Retrieve the mode of the first circuit.
match self.get(0) {
match self.first() {
Some(first) => Mode::combine(first.eject_mode(), self.iter().skip(1).map(Eject::eject_mode)),
None => Mode::Constant,
// None => panic!("Attempted to eject the mode on an empty circuit"),
Expand Down
2 changes: 1 addition & 1 deletion ledger/authority/src/serialize.rs
Expand Up @@ -55,7 +55,7 @@ impl<'de, N: Network> Deserialize<'de> for Authority<N> {
"quorum" => Ok(Self::from_quorum(
DeserializeExt::take_from_value::<D>(&mut authority, "subdag").map_err(de::Error::custom)?,
)),
_ => Err(error("Invalid authority type")).map_err(de::Error::custom),
_ => Err(de::Error::custom(error("Invalid authority type"))),
}
}
false => FromBytesDeserializer::<Self>::deserialize_with_size_encoding(deserializer, "authority"),
Expand Down
2 changes: 1 addition & 1 deletion ledger/block/src/serialize.rs
Expand Up @@ -60,7 +60,7 @@ impl<'de, N: Network> Deserialize<'de> for Block<N> {
// Ensure the block hash matches.
match block_hash == block.hash() {
true => Ok(block),
false => Err(error("Mismatching block hash, possible data corruption")).map_err(de::Error::custom),
false => Err(de::Error::custom(error("Mismatching block hash, possible data corruption"))),
}
}
false => FromBytesDeserializer::<Self>::deserialize_with_size_encoding(deserializer, "block"),
Expand Down
2 changes: 1 addition & 1 deletion ledger/block/src/transaction/fee/mod.rs
Expand Up @@ -78,7 +78,7 @@ impl<N: Network> Fee<N> {
pub fn payer(&self) -> Option<Address<N>> {
// Retrieve the payer.
match self.transition.outputs().last() {
Some(Output::Future(_, Some(future))) => match future.arguments().get(0) {
Some(Output::Future(_, Some(future))) => match future.arguments().first() {
Some(Argument::Plaintext(Plaintext::Literal(Literal::Address(address), _))) => Some(*address),
_ => None,
},
Expand Down
4 changes: 1 addition & 3 deletions ledger/block/src/transaction/serialize.rs
Expand Up @@ -100,9 +100,7 @@ impl<'de, N: Network> Deserialize<'de> for Transaction<N> {
// Ensure the transaction ID matches.
match id == transaction.id() {
true => Ok(transaction),
false => {
Err(error("Mismatching transaction ID, possible data corruption")).map_err(de::Error::custom)
}
false => Err(de::Error::custom(error("Mismatching transaction ID, possible data corruption"))),
}
}
false => FromBytesDeserializer::<Self>::deserialize_with_size_encoding(deserializer, "transaction"),
Expand Down
2 changes: 1 addition & 1 deletion ledger/block/src/transition/serialize.rs
Expand Up @@ -67,7 +67,7 @@ impl<'de, N: Network> Deserialize<'de> for Transition<N> {
// Ensure the transition ID is correct.
match id == *transition.id() {
true => Ok(transition),
false => Err(error("Transition ID mismatch, possible data corruption")).map_err(de::Error::custom),
false => Err(de::Error::custom(error("Transition ID mismatch, possible data corruption"))),
}
}
false => FromBytesDeserializer::<Self>::deserialize_with_size_encoding(deserializer, "transition"),
Expand Down
8 changes: 4 additions & 4 deletions ledger/narwhal/batch-header/src/serialize.rs
Expand Up @@ -58,10 +58,10 @@ impl<'de, N: Network> Deserialize<'de> for BatchHeader<N> {
// Ensure that the batch ID matches the recovered header.
match batch_id == batch_header.batch_id() {
true => Ok(batch_header),
false => {
Err(error(format!("Batch ID mismatch: expected {batch_id}, got {}", batch_header.batch_id())))
.map_err(de::Error::custom)
}
false => Err(de::Error::custom(error(format!(
"Batch ID mismatch: expected {batch_id}, got {}",
batch_header.batch_id()
)))),
}
}
false => FromBytesDeserializer::<Self>::deserialize_with_size_encoding(deserializer, "batch header"),
Expand Down
8 changes: 4 additions & 4 deletions ledger/narwhal/data/src/lib.rs
Expand Up @@ -206,17 +206,17 @@ impl<'de, T: FromBytes + ToBytes + DeserializeOwned + Send + 'static> Deserializ
// Decode from bech32m.
let (hrp, data, variant) = bech32::decode(&encoding).map_err(de::Error::custom)?;
if hrp != PREFIX {
return Err(error(format!("Invalid data HRP - {hrp}"))).map_err(de::Error::custom);
return Err(de::Error::custom(error(format!("Invalid data HRP - {hrp}"))));
};
if data.is_empty() {
return Err(error("Invalid bech32m data (empty)")).map_err(de::Error::custom);
return Err(de::Error::custom(error("Invalid bech32m data (empty)")));
}
if variant != bech32::Variant::Bech32m {
return Err(error("Invalid data - variant is not bech32m")).map_err(de::Error::custom);
return Err(de::Error::custom(error("Invalid data - variant is not bech32m")));
}
Ok(Self::Buffer(Bytes::from(Vec::from_base32(&data).map_err(de::Error::custom)?)))
}
_ => Err(error(format!("Invalid data type - {type_}"))).map_err(de::Error::custom),
_ => Err(de::Error::custom(error(format!("Invalid data type - {type_}")))),
}
}
false => FromBytesDeserializer::<Self>::deserialize_with_size_encoding(deserializer, "data"),
Expand Down
2 changes: 1 addition & 1 deletion ledger/narwhal/transmission/src/serialize.rs
Expand Up @@ -61,7 +61,7 @@ impl<'de, N: Network> Deserialize<'de> for Transmission<N> {
DeserializeExt::take_from_value::<D>(&mut transmission, "transmission")
.map_err(de::Error::custom)?,
)),
_ => Err(error("Invalid transmission type")).map_err(de::Error::custom),
_ => Err(de::Error::custom(error("Invalid transmission type"))),
}
}
false => FromBytesDeserializer::<Self>::deserialize_with_size_encoding(deserializer, "transmission"),
Expand Down
2 changes: 1 addition & 1 deletion ledger/puzzle/src/solution/serialize.rs
Expand Up @@ -51,7 +51,7 @@ impl<'de, N: Network> Deserialize<'de> for Solution<N> {
// Ensure the solution ID matches.
match solution_id == solution.id() {
true => Ok(solution),
false => Err(error("Mismatching solution ID, possible data corruption")).map_err(de::Error::custom),
false => Err(de::Error::custom(error("Mismatching solution ID, possible data corruption"))),
}
}
false => FromBytesDeserializer::<Self>::deserialize_with_size_encoding(deserializer, "solution"),
Expand Down
2 changes: 1 addition & 1 deletion ledger/store/src/block/confirmed_tx_type/serialize.rs
Expand Up @@ -83,7 +83,7 @@ impl<'de, N: Network> Deserialize<'de> for ConfirmedTxType<N> {
.map_err(de::Error::custom)?;
Ok(Self::RejectedExecute(index, rejected))
}
_ => Err(error("Invalid confirmed transaction type")).map_err(de::Error::custom),
_ => Err(de::Error::custom(error("Invalid confirmed transaction type"))),
}
}
false => FromBytesDeserializer::<Self>::deserialize_with_size_encoding(
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
@@ -1 +1 @@
1.72.1
1.76.0
2 changes: 1 addition & 1 deletion synthesizer/process/src/stack/authorization/mod.rs
Expand Up @@ -120,7 +120,7 @@ impl<N: Network> Authorization<N> {
impl<N: Network> Authorization<N> {
/// Returns the next `Request` in the authorization.
pub fn peek_next(&self) -> Result<Request<N>> {
self.requests.read().get(0).cloned().ok_or_else(|| anyhow!("Failed to peek at the next request."))
self.requests.read().front().cloned().ok_or_else(|| anyhow!("Failed to peek at the next request."))
}

/// Returns the next `Request` from the authorization.
Expand Down
2 changes: 1 addition & 1 deletion synthesizer/process/src/stack/call/mod.rs
Expand Up @@ -404,7 +404,7 @@ impl<N: Network> CallTrait<N> for Call<N> {
// Compute the transition commitment as `Hash(tvk)`.
let candidate_tcm = A::hash_psd2(&[tvk.clone()]);
// Ensure the transition commitment matches the computed transition commitment.
A::assert_eq(&tcm, &candidate_tcm);
A::assert_eq(&tcm, candidate_tcm);
// Inject the input IDs (from the request) as `Mode::Public`.
let input_ids = request
.input_ids()
Expand Down
2 changes: 1 addition & 1 deletion synthesizer/program/src/import/mod.rs
Expand Up @@ -66,7 +66,7 @@ impl<N: Network> Ord for Import<N> {
impl<N: Network> PartialOrd for Import<N> {
/// Ordering is determined by the NLD first, then the program name second.
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.program_id.partial_cmp(&other.program_id)
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion utilities/src/bytes.rs
Expand Up @@ -456,7 +456,7 @@ impl<'a, T: 'a + ToBytes> ToBytes for &'a T {
}

#[inline]
pub fn bits_from_bytes_le(bytes: &[u8]) -> impl Iterator<Item = bool> + DoubleEndedIterator<Item = bool> + '_ {
pub fn bits_from_bytes_le(bytes: &[u8]) -> impl DoubleEndedIterator<Item = bool> + '_ {
bytes.iter().flat_map(|byte| (0..8).map(move |i| (*byte >> i) & 1 == 1))
}

Expand Down

0 comments on commit 78d449b

Please sign in to comment.