-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turn on pedantic clippy lints where possible (#886)
* Deny clippy::all lint group * clippy::drop_non_drop These drop calls seem not to be necessary. * clippy::cast_lossless Casts, i.e., the `as` syntax, should generally be avoided where possible. They truncate by default, which is dangerous if it isn't what you want. This lint complains about `as` when the cast is lossless, which means you can use `T::from` or `.into()`. I tried to use `.into()` where possible due to type inference, becuase it's slightly nicer, and avoids having to name the types involved. * clippy::checked_conversions This avoids an assert, because on the next line we do the conversion with an unwrap, which has the same effect. * clippy::cloned_instead_of_copied Copied should generally be used where possible, because all types which implement copy implement clone, but not all types which implement copy, so using `.copied()` gives the additional information that the copy is cheap. * clippy::default_trait_access This one is just kind of annoying, forcing you to write `T::default()` instead of `Default::default()`, so just ignore it. * clippy::doc_markdown Clippy wants items in markdown documentation to be inside backticks. Why not, since it makes them formatted nicely. * Ignore benchmark and test temporary files * clippy::explicit_iter_loop `for x in foo.iter()` is equivalent to `for x in &foo`, which is shorter and more idiomatic * Allow clippy::if_not_else This complains if you do `if !x { … } else { … }`, on the basis that you could avoid the `!` and just switch the bodies of the if and else. I like this one, but it's subjective and creates a lot of code churn, so I allowed it. If you like it, think about removing it from the allow block. * Allow clippy::inline_always Clippy doesn't like this and suggests always profiling first, but I have no idea if these instances are correct or not, so allow them. * Allow clippy::iter_not_returning_iterator Clippy complains if the return type from a function called `iter` does not implement `Iterator`. This is an API break or a new implementation of `Iterator`, so just allow it. * Allow clippy::let_underscore_drop Clippy doesn't like if you use `let _ = x` when `x` implements `Drop`, since it's not necessarily clear that `_` will invoke `Drop`. (Unlike an `_`-prefixed identifier, which will not drop.) This is kind of subjective, so allow it. * Deny clippy::map_unwrap_or Clippy prefers `map_or` to `map + unwrap_or`. Why not. * Allow clippy::missing_errors_doc and clippy::missing_panics_doc Clippy wants you to write docs about panics and errors. Probably a good idea, but who has time for that. Allow it. * Deny clippy::match_wildcard_for_single_variants Replace a `_` match for the single variant it matches. Seems reasonable. * Allow clippy::module_name_repetitions Clippy doesn't like repitition of module names inside types. Who cares. Allow it. * Allow clippy::needless_pass_by_value Clippy complains if you pass a type by value when it isn't consumed, so it could be passed by reference. I think this should be evaluated on a case-by-case basis, depending on ergonomics, so allow it. * Allow clippy::option_option `Option<Option<T>>` is clearly an insane type, but I dare not touch it, because I have no idea what it's supposed to mean, so allow it. * Deny clippy::range_plus_one Using `a..=b` is clearer and shorter than `a..(b + 1)`. * Deny clippy::type_repetition_in_bounds In these `where` clauses, `'b` outlives `'a`, so it's enough to declare that `Self: 'b`. * Deny clippy::uninlined_format_args This is nice, since it reminds you where you can inline things in format strings. * Allow clippy::unnecessary_wraps This should probably be denied, but in some cases, a function returns `Result` or `Option` for API compatibility reasons, and I didn't want to wade into that. * Deny clippy::semicolon_if_nothing_returned You can omit a semicolon after a `()` expression, but seems fine to deny it for consistent formatting. Add an exception for this lunacy: fn from_bytes<'a>(_data: &'a [u8]) -> () where Self: 'a, { () } * Allow clippy::too_many_lines You're not the boss of me. * Allow clippy::similar_names This is just silly. I'll make similar names if I want to. * Allow clippy::wildcard_imports More nanny-state bullshit. * Allow clippy::unreadable_literal I do actually think that most of these could use some `_` separators, the decimal literals should be in groups of three, and the hex should be maybe every 4 bytes, or something like that, but this is subjective. * Deny clippy::redundant_else These seem reasonable to remove. These else blocks are after an if block which either returns or breaks the loop, so these get rid of some nesting. * Deny clippy::unused_self It seems clearer to avoid taking `&self` if it isn't used, and these aren't public APIs, so it's backwards compatible. * Allow clippy::must_use_candidate This is a reasonable lint, but it's subjective and would be a larger change, so I was too lazy to do it. * Deny clippy::match_same_arms Match arms with duplicate captures and bodies can be deduplicated. Seems reasonable to me. * Deny clippy::trivially_copy_pass_by_ref This seems reasonable, small copy values should be passed by value. * Allow clippy::redundant_closure_for_method_calls I think this is actually a good one, but fixing it was annoying, so allow it. * Deny clippy::transmute_ptr_to_ptr Clippy doesn't like mem::transmute for transmuting pointers to pointers. I think the logic is that `mem::transmute` will transmute absolutely any type into any other type, as long as they're the same size. A pointer cast is much more limited, so it seems reasonable to use it instead. * Sort and clean up allow and deny blocks * Use pointer::cast * Revert changes to xxh3 and allow lints
- Loading branch information
Showing
26 changed files
with
179 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,6 @@ Cargo.lock | |
# Profiling | ||
perf.data* | ||
flamegraph.svg | ||
|
||
# benchmark and test temporary files | ||
/.tmp* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.