cosmos / ibc-rs

Rust implementation of the Inter-Blockchain Communication (IBC) protocol.
Apache License 2.0
182 stars 74 forks source link

imp(ibc-core): shadowing with the same value #1120

Closed rnbguy closed 3 months ago

rnbguy commented 3 months ago

Bug Summary

The following two cases are caught by clippy::shadow_unrelated. There are other cases, but these two cases are special as they are using the exact same value. So we can remove the shadowing and use the first binding directly.

https://github.com/cosmos/ibc-rs/blob/e1f19af161878f9daf779aed0f19229f97d54814/ibc-core/ics04-channel/src/handler/acknowledgement.rs#L55-L59

is shadowed by

https://github.com/cosmos/ibc-rs/blob/e1f19af161878f9daf779aed0f19229f97d54814/ibc-core/ics04-channel/src/handler/acknowledgement.rs#L77-L81

Since msg is immutable, both are the same. We can remove second one and use the previous variable directly.

https://github.com/cosmos/ibc-rs/blob/e1f19af161878f9daf779aed0f19229f97d54814/ibc-core/ics04-channel/src/handler/timeout.rs#L67-L68

is shadowed by

https://github.com/cosmos/ibc-rs/blob/e1f19af161878f9daf779aed0f19229f97d54814/ibc-core/ics04-channel/src/handler/timeout.rs#L85-L89

Since packet is immutable, we can use previous one directly.

Details

Version

<= 0.50.0