-
Notifications
You must be signed in to change notification settings - Fork 87
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
Deny clippy::arithmetic_side_effects for fuel-merkle #729
Conversation
|
||
impl<T> ComparablePath for T |
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.
Merged into Path
trait, as they were not used separately.
|
||
pub enum Instruction { |
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.
Renamed to Side
, and used in more places
@@ -1,50 +1,32 @@ | |||
#[derive(Debug, Eq, PartialEq)] | |||
pub enum Bit { |
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.
Replaced with bool
or Side
enum, depending on which made sense.
trait GetBit { | ||
fn get_bit(&self, bit_index: u32) -> Option<Bit>; | ||
} |
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.
This was used only once, below. I just inlined it.
Co-authored-by: Brandon Vrooman <brandon.vrooman@fuel.sh>
Co-authored-by: Green Baneling <XgreenX9999@gmail.com>
fuel-merkle/src/common/subtree.rs
Outdated
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.
The Subtree
was just a hand-rolled non-empty linked list. It was always used wrapped in an option, so the use was exactly equivalent to a linked list. I first replaced it with alloc::collections::LinkedList
but why not use a normal Vec
instead? Actually MerkleRootCalculator
already does that, so I just replaces all Subtree
instances with it.
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.
LGTM! It would be nice if @bvrooman reviewed the change=)
.checked_sub(1) | ||
.expect("Path to a tree without leaves"), | ||
) | ||
.unwrap(), |
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 think we can't guaranty that this will not fail. Is someone provides invalid leaves_count
, it will fail
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.
If the tree has a root, then leaves_count
will be at least 1. In real use cases, this should be okay. But if someone were to provide arguments that are inconsistent with a real tree, this could fail. I don't think that's an issue.
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.
lgtm
Closes #170
Denies the following lints:
clippy::arithmetic_side_effects
clippy::cast_sign_loss
clippy::cast_possible_truncation
clippy::cast_possible_wrap
Checklist
Before requesting review