Skip to content

Commit b84ff9f

Browse files
rust 1.53.0 updates (#2411)
## Issue Addressed `make lint` failing on rust 1.53.0. ## Proposed Changes 1.53.0 updates ## Additional Info I haven't figure out why yet, we were now hitting the recursion limit in a few crates. So I had to add `#![recursion_limit = "256"]` in a few places Co-authored-by: realbigsean <[email protected]> Co-authored-by: Michael Sproul <[email protected]>
1 parent 3dc1eb5 commit b84ff9f

File tree

32 files changed

+106
-134
lines changed

32 files changed

+106
-134
lines changed

.github/custom/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Custom Cargo config to be used for the udeps CI job
2+
[http]
3+
multiplexing = false

.github/workflows/test-suite.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
# Deny warnings in CI
1313
RUSTFLAGS: "-D warnings"
1414
# The Nightly version used for cargo-udeps, might need updating from time to time.
15-
PINNED_NIGHTLY: nightly-2021-03-01
15+
PINNED_NIGHTLY: nightly-2021-06-09
1616
jobs:
1717
target-branch-check:
1818
name: target-branch-check
@@ -198,6 +198,10 @@ jobs:
198198
run: rustup toolchain install $PINNED_NIGHTLY
199199
- name: Install cargo-udeps
200200
run: cargo install cargo-udeps --locked
201+
- name: Create Cargo config dir
202+
run: mkdir -p .cargo
203+
- name: Install custom Cargo config
204+
run: cp -f .github/custom/config.toml .cargo/config.toml
201205
- name: Run cargo udeps to identify unused crates in the dependency graph
202206
run: make udeps
203207
env:

account_manager/src/validator/create.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ pub fn cli_run<T: EthSpec>(
236236
.map_err(|e| {
237237
format!(
238238
"Error registering validator {}: {:?}",
239-
voting_pubkey.to_hex_string(),
239+
voting_pubkey.as_hex_string(),
240240
e
241241
)
242242
})?;
@@ -250,7 +250,7 @@ pub fn cli_run<T: EthSpec>(
250250
.build()
251251
.map_err(|e| format!("Unable to build validator directory: {:?}", e))?;
252252

253-
println!("{}/{}\t{}", i + 1, n, voting_pubkey.to_hex_string());
253+
println!("{}/{}\t{}", i + 1, n, voting_pubkey.as_hex_string());
254254
}
255255

256256
Ok(())

account_manager/src/validator/import.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), Strin
242242
.map_err(|e| {
243243
format!(
244244
"Error registering validator {}: {:?}",
245-
voting_pubkey.to_hex_string(),
245+
voting_pubkey.as_hex_string(),
246246
e
247247
)
248248
})?;

beacon_node/beacon_chain/src/eth1_chain.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -762,8 +762,8 @@ mod test {
762762

763763
let eth1_chain = get_eth1_chain();
764764

765-
assert_eq!(
766-
eth1_chain.use_dummy_backend, false,
765+
assert!(
766+
!eth1_chain.use_dummy_backend,
767767
"test should not use dummy backend"
768768
);
769769

@@ -795,8 +795,8 @@ mod test {
795795
let eth1_chain = get_eth1_chain();
796796
let max_deposits = <E as EthSpec>::MaxDeposits::to_u64();
797797

798-
assert_eq!(
799-
eth1_chain.use_dummy_backend, false,
798+
assert!(
799+
!eth1_chain.use_dummy_backend,
800800
"test should not use dummy backend"
801801
);
802802

@@ -877,8 +877,8 @@ mod test {
877877

878878
let eth1_chain = get_eth1_chain();
879879

880-
assert_eq!(
881-
eth1_chain.use_dummy_backend, false,
880+
assert!(
881+
!eth1_chain.use_dummy_backend,
882882
"test should not use dummy backend"
883883
);
884884

@@ -901,8 +901,8 @@ mod test {
901901

902902
let eth1_chain = get_eth1_chain();
903903

904-
assert_eq!(
905-
eth1_chain.use_dummy_backend, false,
904+
assert!(
905+
!eth1_chain.use_dummy_backend,
906906
"test should not use dummy backend"
907907
);
908908

beacon_node/beacon_chain/src/state_advance_timer.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,11 @@ mod tests {
353353
#[test]
354354
fn lock() {
355355
let lock = Lock::new();
356-
assert_eq!(lock.lock(), false);
357-
assert_eq!(lock.lock(), true);
358-
assert_eq!(lock.lock(), true);
356+
assert!(!lock.lock());
357+
assert!(lock.lock());
358+
assert!(lock.lock());
359359
lock.unlock();
360-
assert_eq!(lock.lock(), false);
361-
assert_eq!(lock.lock(), true);
360+
assert!(!lock.lock());
361+
assert!(lock.lock());
362362
}
363363
}

beacon_node/eth2_libp2p/src/discovery/enr_ext.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,22 @@ impl EnrExt for Enr {
8888
if let Some(udp) = self.udp() {
8989
let mut multiaddr: Multiaddr = ip.into();
9090
multiaddr.push(Protocol::Udp(udp));
91-
multiaddr.push(Protocol::P2p(peer_id.clone().into()));
91+
multiaddr.push(Protocol::P2p(peer_id.into()));
9292
multiaddrs.push(multiaddr);
9393
}
9494

9595
if let Some(tcp) = self.tcp() {
9696
let mut multiaddr: Multiaddr = ip.into();
9797
multiaddr.push(Protocol::Tcp(tcp));
98-
multiaddr.push(Protocol::P2p(peer_id.clone().into()));
98+
multiaddr.push(Protocol::P2p(peer_id.into()));
9999
multiaddrs.push(multiaddr);
100100
}
101101
}
102102
if let Some(ip6) = self.ip6() {
103103
if let Some(udp6) = self.udp6() {
104104
let mut multiaddr: Multiaddr = ip6.into();
105105
multiaddr.push(Protocol::Udp(udp6));
106-
multiaddr.push(Protocol::P2p(peer_id.clone().into()));
106+
multiaddr.push(Protocol::P2p(peer_id.into()));
107107
multiaddrs.push(multiaddr);
108108
}
109109

@@ -128,7 +128,7 @@ impl EnrExt for Enr {
128128
if let Some(tcp) = self.tcp() {
129129
let mut multiaddr: Multiaddr = ip.into();
130130
multiaddr.push(Protocol::Tcp(tcp));
131-
multiaddr.push(Protocol::P2p(peer_id.clone().into()));
131+
multiaddr.push(Protocol::P2p(peer_id.into()));
132132
multiaddrs.push(multiaddr);
133133
}
134134
}
@@ -154,7 +154,7 @@ impl EnrExt for Enr {
154154
if let Some(udp) = self.udp() {
155155
let mut multiaddr: Multiaddr = ip.into();
156156
multiaddr.push(Protocol::Udp(udp));
157-
multiaddr.push(Protocol::P2p(peer_id.clone().into()));
157+
multiaddr.push(Protocol::P2p(peer_id.into()));
158158
multiaddrs.push(multiaddr);
159159
}
160160
}

beacon_node/eth2_libp2p/src/peer_manager/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -556,20 +556,18 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
556556
if known_meta_data.seq_number < meta_data.seq_number {
557557
debug!(self.log, "Updating peer's metadata";
558558
"peer_id" => %peer_id, "known_seq_no" => known_meta_data.seq_number, "new_seq_no" => meta_data.seq_number);
559-
peer_info.meta_data = Some(meta_data);
560559
} else {
561560
debug!(self.log, "Received old metadata";
562561
"peer_id" => %peer_id, "known_seq_no" => known_meta_data.seq_number, "new_seq_no" => meta_data.seq_number);
563562
// Updating metadata even in this case to prevent storing
564563
// incorrect `metadata.attnets` for a peer
565-
peer_info.meta_data = Some(meta_data);
566564
}
567565
} else {
568566
// we have no meta-data for this peer, update
569567
debug!(self.log, "Obtained peer's metadata";
570568
"peer_id" => %peer_id, "new_seq_no" => meta_data.seq_number);
571-
peer_info.meta_data = Some(meta_data);
572569
}
570+
peer_info.meta_data = Some(meta_data);
573571
} else {
574572
crit!(self.log, "Received METADATA from an unknown peer";
575573
"peer_id" => %peer_id);
@@ -583,11 +581,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
583581
// port is removed, which is assumed to be associated with the discv5 protocol (and
584582
// therefore irrelevant for other libp2p components).
585583
let mut out_list = enr.multiaddr();
586-
out_list.retain(|addr| {
587-
addr.iter()
588-
.find(|v| matches!(v, MProtocol::Udp(_)))
589-
.is_none()
590-
});
584+
out_list.retain(|addr| !addr.iter().any(|v| matches!(v, MProtocol::Udp(_))));
591585

592586
out_list
593587
} else {

beacon_node/eth2_libp2p/src/peer_manager/peer_sync_status.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ impl PeerSyncStatus {
6262
matches!(self, PeerSyncStatus::Behind { .. })
6363
}
6464

65+
/// Updates the peer's sync status, returning whether the status transitioned.
66+
///
67+
/// E.g. returns `true` if the state changed from `Synced` to `Advanced`, but not if
68+
/// the status remained `Synced` with different `SyncInfo` within.
6569
pub fn update(&mut self, new_state: PeerSyncStatus) -> bool {
66-
if *self == new_state {
67-
*self = new_state;
68-
false // state was not updated
69-
} else {
70-
*self = new_state;
71-
true
72-
}
70+
let changed_status = *self != new_state;
71+
*self = new_state;
72+
changed_status
7373
}
7474

7575
pub fn as_str(&self) -> &'static str {

beacon_node/eth2_libp2p/src/rpc/handler.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ where
587587
match std::mem::replace(&mut info.state, InboundState::Poisoned) {
588588
InboundState::Idle(substream) if !deactivated => {
589589
if !info.pending_items.is_empty() {
590-
let to_send = std::mem::replace(&mut info.pending_items, vec![]);
590+
let to_send = std::mem::take(&mut info.pending_items);
591591
let fut = process_inbound_substream(
592592
substream,
593593
info.remaining_chunks,
@@ -665,8 +665,7 @@ where
665665
// elements
666666

667667
if !deactivated && !info.pending_items.is_empty() {
668-
let to_send =
669-
std::mem::replace(&mut info.pending_items, vec![]);
668+
let to_send = std::mem::take(&mut info.pending_items);
670669
let fut = process_inbound_substream(
671670
substream,
672671
info.remaining_chunks,

0 commit comments

Comments
 (0)