fix(rust): Make Zebra build with the latest nightly Rust (#5738)

* Remove an unused async track_caller which will soon become a warning

* Explicitly drop unused futures

* Work around a compiler panic (ICE) with flat_map()

https://github.com/rust-lang/rust/issues/105044

* Remove a redundant into_iter()

* allow(clippy::needless_collect)
This commit is contained in:
teor 2022-11-30 17:03:24 +10:00 committed by GitHub
parent 1497f2d199
commit 26ff1b4fb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 10 deletions

View File

@ -149,9 +149,16 @@ impl Block {
/// Access the [`orchard::Nullifier`]s from all transactions in this block.
pub fn orchard_nullifiers(&self) -> impl Iterator<Item = &orchard::Nullifier> {
self.transactions
// Work around a compiler panic (ICE) with flat_map():
// https://github.com/rust-lang/rust/issues/105044
#[allow(clippy::needless_collect)]
let nullifiers: Vec<_> = self
.transactions
.iter()
.flat_map(|transaction| transaction.orchard_nullifiers())
.collect();
nullifiers.into_iter()
}
/// Count how many Sapling transactions exist in a block,

View File

@ -120,7 +120,6 @@ async fn connect_isolated_sends_anonymised_version_message_mem_net(network: Netw
/// Wait to receive a version message on `inbound_stream`,
/// then check that it is correctly anonymised.
#[track_caller]
async fn check_version_message<PeerTransport>(
network: Network,
inbound_stream: &mut Framed<PeerTransport, Codec>,

View File

@ -90,10 +90,12 @@ impl ClientTestHarness {
/// Drops the mocked heartbeat shutdown receiver endpoint.
pub fn drop_heartbeat_shutdown_receiver(&mut self) {
let _ = self
let hearbeat_future = self
.shutdown_receiver
.take()
.expect("heartbeat shutdown receiver endpoint has already been dropped");
.expect("unexpected test failure: heartbeat shutdown receiver endpoint has already been dropped");
std::mem::drop(hearbeat_future);
}
/// Closes the receiver endpoint of [`ClientRequest`]s that are supposed to be sent to the

View File

@ -145,7 +145,8 @@ proptest! {
}
// Send a request to all peers
let _ = peer_set.route_broadcast(Request::AdvertiseBlock(block_hash));
let response_future = peer_set.route_broadcast(Request::AdvertiseBlock(block_hash));
std::mem::drop(response_future);
// Check how many peers received the request
let mut received = 0;
@ -213,7 +214,8 @@ proptest! {
let number_of_peers_to_broadcast = peer_set.number_of_peers_to_broadcast();
// Send a request to all peers we have now
let _ = peer_set.route_broadcast(Request::AdvertiseBlock(block_hash));
let response_future = peer_set.route_broadcast(Request::AdvertiseBlock(block_hash));
std::mem::drop(response_future);
// Check how many peers received the request
let mut received = 0;
@ -273,7 +275,8 @@ proptest! {
}
// this will panic as expected
let _ = peer_set.route_broadcast(Request::AdvertiseBlock(block_hash));
let response_future = peer_set.route_broadcast(Request::AdvertiseBlock(block_hash));
std::mem::drop(response_future);
Ok::<_, TestCaseError>(())
})?;

View File

@ -33,11 +33,13 @@ pub(crate) fn block_precommit_metrics(block: &Block, hash: block::Hash, height:
.flat_map(|t| t.sapling_nullifiers())
.count();
let orchard_nullifier_count = block
// Work around a compiler panic (ICE) with flat_map():
// https://github.com/rust-lang/rust/issues/105044
let orchard_nullifier_count: usize = block
.transactions
.iter()
.flat_map(|t| t.orchard_nullifiers())
.count();
.map(|t| t.orchard_nullifiers().count())
.sum();
tracing::debug!(
?hash,