Skip to content

Commit

Permalink
Update Rust toolchain to 1.78.0
Browse files Browse the repository at this point in the history
Cargo.lock was updated to version 4 manually.
All Git refs in our Cargo.lock appear to be encoded correctly.
See:
- rust-lang/cargo#12280
- rust-lang/cargo#12852

The clippy::incompatible_msrv lint may be useful in the future.
We currently do not specify rust-version in Cargo.toml.
Our libraries are not designed to be used outside Grandine.
rust-toolchain.toml makes rust-version redundant for builds inside this repository.
See:
- https://doc.rust-lang.org/1.78.0/cargo/reference/manifest.html#the-rust-version-field
- https://rust-lang.github.io/rust-clippy/rust-1.78.0/#/incompatible_msrv

The clippy::lint_groups_priority lint produces false positives:
- rust-lang/cargo#12918 (comment)
- rust-lang/rust-clippy#12270
Luckily, lints inherited from a workspace do not trigger it.
The issue appears to be fixed in rust-lang/rust-clippy#12827.

The reason public functions trigger clippy::single_call_fn is actually our setting of avoid-breaking-exported-api.
We assumed it was a bug.
  • Loading branch information
weekday-grandine-io committed May 25, 2024
1 parent 06ce993 commit e0607e1
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ let_underscore_drop = 'warn'
macro_use_extern_crate = 'warn'
meta_variable_misuse = 'warn'
non_ascii_idents = 'warn'
non_local_definitions = 'warn'
trivial_casts = 'warn'
trivial_numeric_casts = 'warn'
unit_bindings = 'warn'
Expand Down Expand Up @@ -140,7 +141,7 @@ wildcard_dependencies = 'warn'
#
# - `clippy::single_call_fn`.
# It's unidiomatic and conflicts with lints like `clippy::too_many_lines`.
# Public functions are not exempt from it as of Rust 1.77.2.
# Public functions are not exempt from it if `avoid-breaking-exported-api` is `false`.
#
# - `clippy::std_instead_of_alloc`
# It would require adding `extern crate alloc;` everywhere.
Expand Down
2 changes: 1 addition & 1 deletion benches/benches/hashing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn main() {
criterion.final_summary();
}

// Arrays of arbitrary length do not implement `Default` as of Rust 1.77.2.
// Arrays of arbitrary length do not implement `Default` as of Rust 1.78.0.
// See <https://github.com/rust-lang/rust/issues/61415>.
// We work around that by using `PublicKeyBytes` and `SignatureBytes` instead.

Expand Down
3 changes: 3 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
avoid-breaking-exported-api = false
doc-valid-idents = [
'..',
'Eth1Data',
'PoS',
'PoW',
'RocksDB',
'UPnP',
'Web3Signer',
]
# There appears to be no way to disallow an entire module.
# There is an issue for it at <https://github.com/rust-lang/rust-clippy/issues/9489>.
Expand Down
6 changes: 3 additions & 3 deletions fork_choice_control/src/mutator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ where
.blob_kzg_commitments()
.iter()
.copied()
.map(helper_functions::misc::kzg_commitment_to_versioned_hash)
.map(misc::kzg_commitment_to_versioned_hash)
.collect();

params = Some(ExecutionPayloadParams::Deneb {
Expand Down Expand Up @@ -2007,7 +2007,7 @@ where

let mut gossip_ids = vec![];

// Use `drain_filter_polyfill` because `Vec::extract_if` is not stable as of Rust 1.77.2.
// Use `drain_filter_polyfill` because `Vec::extract_if` is not stable as of Rust 1.78.0.
self.delayed_until_block.retain(|_, delayed| {
let Delayed {
blocks,
Expand Down Expand Up @@ -2081,7 +2081,7 @@ where

let mut gossip_ids = vec![];

// Use `HashMap::retain` because `HashMap::extract_if` is not stable as of Rust 1.77.2.
// Use `HashMap::retain` because `HashMap::extract_if` is not stable as of Rust 1.78.0.
self.waiting_for_checkpoint_states
.retain(|target, waiting| {
let prune = target.epoch < finalized_epoch;
Expand Down
4 changes: 4 additions & 0 deletions grandine/src/grandine_args.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Adding backquotes to doc comments affects `--help` output.
// `clap` derive macros preserve backquotes even if `verbatim_doc_comment` is disabled.
#![allow(clippy::doc_markdown)]

use core::{
fmt::Display,
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
Expand Down
2 changes: 1 addition & 1 deletion http_api/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl Error {
self.sources().format(": ")
}

// `StdError::sources` is not stable as of Rust 1.77.2.
// `StdError::sources` is not stable as of Rust 1.78.0.
fn sources(&self) -> impl Iterator<Item = &dyn StdError> {
let mut error: Option<&dyn StdError> = Some(self);

Expand Down
2 changes: 1 addition & 1 deletion http_api_utils/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Error {
self.sources().format(": ")
}

// `StdError::sources` is not stable as of Rust 1.77.2.
// `StdError::sources` is not stable as of Rust 1.78.0.
fn sources(&self) -> impl Iterator<Item = &dyn StdError> {
let mut error: Option<&dyn StdError> = Some(self);

Expand Down
6 changes: 3 additions & 3 deletions p2p/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use eth2_libp2p::{
};
use fork_choice_control::P2pMessage;
use futures::{
channel::mpsc::{self, Receiver, UnboundedReceiver, UnboundedSender},
channel::mpsc::{Receiver, UnboundedReceiver, UnboundedSender},
future::FutureExt as _,
select,
stream::StreamExt as _,
Expand Down Expand Up @@ -174,8 +174,8 @@ impl<P: Preset> Network<P> {
}
}

let (network_to_service_tx, network_to_service_rx) = mpsc::unbounded();
let (service_to_network_tx, service_to_network_rx) = mpsc::unbounded();
let (network_to_service_tx, network_to_service_rx) = futures::channel::mpsc::unbounded();
let (service_to_network_tx, service_to_network_rx) = futures::channel::mpsc::unbounded();

run_network_service(service, network_to_service_rx, service_to_network_tx);

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = 'stable-2024-04-09'
channel = 'stable-2024-05-02'
profile = 'minimal'
components = ['clippy', 'rustfmt']
2 changes: 1 addition & 1 deletion ssz/src/merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl<D: ArrayLength<H256>> MerkleTree<D> {
// ```
// See <https://oeis.org/A003817>.
//
// `usize::saturating_shr` does not exist as of Rust 1.77.2.
// `usize::saturating_shr` does not exist as of Rust 1.78.0.
let filled_left_subtree = usize::MAX
.checked_shr(chunk_indices.start.leading_ones())
.unwrap_or_default();
Expand Down
7 changes: 7 additions & 0 deletions ssz/src/persistent_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,13 @@ impl<T, B: BundleSize<T>> Node<T, B> {

loop {
match node {
// False positive. See:
// - <https://github.com/rust-lang/rust-clippy/issues/12444>
// - <https://github.com/rust-lang/rust-clippy/issues/12460>
// - <https://github.com/rust-lang/rust-clippy/issues/12467>
// - <https://github.com/rust-lang/rust-clippy/issues/12749>
// - <https://github.com/rust-lang/rust-clippy/issues/12757>
#[allow(clippy::assigning_clones)]
Self::Internal {
left, left_height, ..
} if B::depth_of_length(length) <= *left_height => {
Expand Down
2 changes: 1 addition & 1 deletion validator/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl Error {
self.sources().format(": ")
}

// `StdError::sources` is not stable as of Rust 1.77.2.
// `StdError::sources` is not stable as of Rust 1.78.0.
fn sources(&self) -> impl Iterator<Item = &dyn StdError> {
let mut error: Option<&dyn StdError> = Some(self);

Expand Down
4 changes: 2 additions & 2 deletions validator/src/own_sync_committee_subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl<P: Preset> OwnSyncCommitteeSubscriptions<P> {
let next_period = current_period + 1;
let next_period_start = misc::start_of_sync_committee_period::<P>(next_period);

if self.subscriptions.get(&current_period).is_none() {
if self.subscriptions.contains_key(&current_period) {
let subscriptions = core::iter::repeat(current_epoch)
.zip(sync_committee_subscriptions(
state,
Expand All @@ -44,7 +44,7 @@ impl<P: Preset> OwnSyncCommitteeSubscriptions<P> {
self.subscriptions.insert(current_period, subscriptions);
}

if self.subscriptions.get(&next_period).is_none() {
if self.subscriptions.contains_key(&next_period) {
let next_period_expiration = misc::start_of_sync_committee_period::<P>(next_period + 1);

let mut rng = rand::thread_rng();
Expand Down

0 comments on commit e0607e1

Please sign in to comment.