-
Notifications
You must be signed in to change notification settings - Fork 109
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
rust: setup clippy lints and fix existing lint issues #4455
Conversation
d8c7b46
to
8fa4652
Compare
Codecov Report
@@ Coverage Diff @@
## master #4455 +/- ##
==========================================
+ Coverage 68.66% 68.83% +0.17%
==========================================
Files 415 415
Lines 46571 46799 +228
==========================================
+ Hits 31976 32214 +238
+ Misses 10635 10625 -10
Partials 3960 3960
Continue to review full report at Codecov.
|
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.
runtime/src/common/key_format.rs
Outdated
if data.len() < 1 + Self::size() { | ||
panic!("key format: malformed input"); | ||
} | ||
assert!(data.len() > Self::size(), "key format: malformed input"); |
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'd somehow find this more understandable with data.len() >= 1 + Self::size()
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.
Clippy disagrees: https://rust-lang.github.io/rust-clippy/master/index.html#int_plus_one
but we can disable that rule if we prefer not to enforce 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.
we could make it more formal
const VERSION_PREFIX_SIZE: usize = the_size_of_a_u8;
data.len() >= VERSION_PREFIX_SIZE + Self:size()
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.
or let's go with clippy's (probably less thoughtful) recommendation and add a comment about "must be strictly greater than because there must additionally be a version prefix thingy"
addendum: "and the prefix is exactly one byte, so it suffices only to use > instead of >=. marvel at our resourcefulness"
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.
Ah I see, I thought you generally preferred the 1+
version. Yeah I can make this case clearer.
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 updated the code with the VERSION_PREFIX_SIZE
approach.
d847286
to
6094e68
Compare
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.
50/74
} | ||
|
||
/// Callback type used for updating cache items after a commit. | ||
pub type CacheUpdater<C> = Box<dyn Fn(&mut C)>; |
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.
ℹ️ -> ()
removed
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.
runtime/src/storage/mkvs/tree/mod.rs
Outdated
} | ||
|
||
/// Commit the options set so far into a newly constructed tree instance. | ||
pub fn new_tree(self, read_syncer: Box<dyn ReadSync>) -> Tree { |
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 replaces new
. and other minor doesn't-affect-interface changes below
- couple of if { panic } changed to assert
- field: field shorthand
- vec ref to slice
if let NodeKind::Internal = classify_noderef!(nd_child) { | ||
if let NodeBox::Internal(ref mut inode) = *nd_child.borrow_mut() | ||
{ | ||
inode.label = noderef_as!(node_ref, Internal).label.merge( |
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.
lol this macro work is scary
3d73468
to
5280ba6
Compare
ee6bd85
to
154cce9
Compare
154cce9
to
cb18563
Compare
Fixes: #4170