-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
@@ -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), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
smol nit, otherwise lgtm
@@ -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), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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());
}
}
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We love lints :)
No description provided.