Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clippy: add collection_is_never_read clippy lint #10703

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ rustdoc.all = "warn"
branches_sharing_code = "warn"
clear_with_drain = "warn"
cloned_instead_of_copied = "warn"
collection_is_never_read = "warn"
derive_partial_eq_without_eq = "warn"
doc_markdown = "warn"
empty_line_after_doc_comments = "warn"
Expand Down Expand Up @@ -231,7 +232,6 @@ zero_sized_map_values = "warn"
# Explicitly listing should make it easier to fix in the future.
as_ptr_cast_mut = "allow"
cognitive_complexity = "allow"
collection_is_never_read = "allow"
debug_assert_with_mut_call = "allow"
fallible_impl_from = "allow"
future_not_send = "allow"
Expand Down
2 changes: 1 addition & 1 deletion crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ impl From<Genesis> for ChainSpec {
chain: genesis.config.chain_id.into(),
genesis,
genesis_hash: None,
hardforks: ChainHardforks::new(hardforks),
hardforks: ChainHardforks::new(ordered_hardforks),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I'm not 100% sure but the ordered_hardforks collection was never read before and I have the impression that we are setting up on the few previous lines an ordering mechanism to use the ordered_hardforks here otherwise it has no interest right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not too sure what this is even used for, cc @joshieDo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any difference between using it or not but maybe there are exceptions that I don't have in mind.

If this is not used, we can simply delete the whole block of code before:

// Uses ethereum or optimism main chains to find proper order
        #[cfg(not(feature = "optimism"))]
        let mainnet_hardforks: ChainHardforks = EthereumHardfork::mainnet().into();
        #[cfg(not(feature = "optimism"))]
        let mainnet_order = mainnet_hardforks.forks_iter();
        #[cfg(feature = "optimism")]
        let mainnet_hardforks = OptimismHardfork::op_mainnet();
        #[cfg(feature = "optimism")]
        let mainnet_order = mainnet_hardforks.forks_iter();

        let mut ordered_hardforks = Vec::with_capacity(hardforks.len());
        for (hardfork, _) in mainnet_order {
            if let Some(pos) = hardforks.iter().position(|(e, _)| **e == *hardfork) {
                ordered_hardforks.push(hardforks[pos].clone());
            }
        }

Copy link
Collaborator

@joshieDo joshieDo Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually this is a bug, and it should be hardforks: ChainHardforks::new(ordered_hardforks) as suggested, mb

lint already doing work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We love lints :)

paris_block_and_final_difficulty,
deposit_contract,
#[cfg(feature = "optimism")]
Expand Down
6 changes: 0 additions & 6 deletions crates/rpc/rpc-testing-util/src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ mod tests {
let mut stream = client.replay_transactions(transactions, trace_types);
let mut successes = 0;
let mut failures = 0;
let mut all_results = Vec::new();

assert_is_stream(&stream);

Expand All @@ -554,12 +553,10 @@ mod tests {
Ok((trace_result, tx_hash)) => {
println!("Success for tx_hash {tx_hash:?}: {trace_result:?}");
successes += 1;
all_results.push(Ok((trace_result, tx_hash)));
}
Err((error, tx_hash)) => {
println!("Error for tx_hash {tx_hash:?}: {error:?}");
failures += 1;
all_results.push(Err((error, tx_hash)));
}
}
}
Expand Down Expand Up @@ -656,7 +653,6 @@ mod tests {
let mut stream = client.trace_call_stream(trace_call_request);
let mut successes = 0;
let mut failures = 0;
let mut all_results = Vec::new();

assert_is_stream(&stream);

Expand All @@ -665,12 +661,10 @@ mod tests {
Ok(trace_result) => {
println!("Success: {trace_result:?}");
successes += 1;
all_results.push(Ok(trace_result));
}
Err((error, request)) => {
println!("Error for request {request:?}: {error:?}");
failures += 1;
all_results.push(Err((error, request)));
}
}
}
Expand Down
Loading