Skip to content

Commit

Permalink
Move #[allow(dead_code)] to field level.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmygchen committed Feb 5, 2024
1 parent 42db70a commit 774e0fc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 25 deletions.
3 changes: 1 addition & 2 deletions beacon_node/beacon_chain/src/state_advance_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ const MAX_BLOCK_PRODUCTION_CACHE_DISTANCE: u64 = 4;
enum Error {
BeaconChain(BeaconChainError),
// We don't use the inner value directly, but it's used in the Debug impl.
#[allow(dead_code)]
HeadMissingFromSnapshotCache(Hash256),
HeadMissingFromSnapshotCache(#[allow(dead_code)] Hash256),
MaxDistanceExceeded {
current_slot: Slot,
head_slot: Slot,
Expand Down
3 changes: 1 addition & 2 deletions beacon_node/execution_layer/src/test_utils/mock_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ impl Operation {
}

#[derive(Debug)]
#[allow(dead_code)]
// We don't use the string value directly, but it's used in the Debug impl which is required by `warp::reject::Reject`.
struct Custom(String);
struct Custom(#[allow(dead_code)] String);

impl warp::reject::Reject for Custom {}

Expand Down
1 change: 0 additions & 1 deletion beacon_node/execution_layer/src/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ pub struct StaticNewPayloadResponse {
should_import: bool,
}
#[derive(Debug)]
#[allow(dead_code)]
// We don't use the string value directly, but it's used in the Debug impl which is required by `warp::reject::Reject`.
struct AuthError(String);

Expand Down
9 changes: 4 additions & 5 deletions beacon_node/http_api/src/attestation_performance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ const BLOCK_ROOT_CHUNK_SIZE: usize = 100;

#[derive(Debug)]
// We don't use the inner values directly, but they're used in the Debug impl.
#[allow(dead_code)]
enum AttestationPerformanceError {
BlockReplay(BlockReplayError),
BeaconState(BeaconStateError),
ParticipationCache(ParticipationCacheError),
UnableToFindValidator(usize),
BlockReplay(#[allow(dead_code)] BlockReplayError),
BeaconState(#[allow(dead_code)] BeaconStateError),
ParticipationCache(#[allow(dead_code)] ParticipationCacheError),
UnableToFindValidator(#[allow(dead_code)] usize),
}

impl From<BlockReplayError> for AttestationPerformanceError {
Expand Down
7 changes: 3 additions & 4 deletions beacon_node/http_api/src/block_packing_efficiency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ const BLOCK_ROOT_CHUNK_SIZE: usize = 100;

#[derive(Debug)]
// We don't use the inner values directly, but they're used in the Debug impl.
#[allow(dead_code)]
enum PackingEfficiencyError {
BlockReplay(BlockReplayError),
BeaconState(BeaconStateError),
CommitteeStoreError(Slot),
BlockReplay(#[allow(dead_code)] BlockReplayError),
BeaconState(#[allow(dead_code)] BeaconStateError),
CommitteeStoreError(#[allow(dead_code)] Slot),
InvalidAttestationError,
}

Expand Down
22 changes: 11 additions & 11 deletions beacon_node/lighthouse_network/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ pub fn fork_context(fork_name: ForkName) -> ForkContext {
ForkContext::new::<E>(current_slot, Hash256::zero(), &chain_spec)
}

pub struct Libp2pInstance {
service: LibP2PService<ReqId, E>,
pub struct Libp2pInstance(
LibP2PService<ReqId, E>,
#[allow(dead_code)]
/// This field is managed for lifetime purposes may not be used directly, hence the `#[allow(dead_code)]` attribute.
exit_signal: exit_future::Signal,
}
// This field is managed for lifetime purposes may not be used directly, hence the `#[allow(dead_code)]` attribute.
exit_future::Signal,
);

impl std::ops::Deref for Libp2pInstance {
type Target = LibP2PService<ReqId, E>;
fn deref(&self) -> &Self::Target {
&self.service
&self.0
}
}

impl std::ops::DerefMut for Libp2pInstance {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.service
&mut self.0
}
}

Expand Down Expand Up @@ -120,13 +120,13 @@ pub async fn build_libp2p_instance(
chain_spec: spec,
libp2p_registry: None,
};
Libp2pInstance {
service: LibP2PService::new(executor, libp2p_context, &log)
Libp2pInstance(
LibP2PService::new(executor, libp2p_context, &log)
.await
.expect("should build libp2p instance")
.0,
exit_signal: signal,
}
signal,
)
}

#[allow(dead_code)]
Expand Down

0 comments on commit 774e0fc

Please sign in to comment.