Fix a bunch of clippy lints #153
No reviewers
Labels
No labels
bug
dependencies
duplicate
enhancement
github_actions
help wanted
invalid
question
rust
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sugar700/enum-map!153
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "martinthomson/enum-map:clippy-fix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Mostly, these are pretty simple. I ran
cargo clippy --fix, which madea bunch of changes that are all OK.
There are a few that required manual intervention. I included a few
suppressions, with reasons. Other changes include: variable renames,
pass by reference rather than value, use of
assert!()rather thanif _ { panic!() }, and probably the biggest change which is to havethe derive macro return a compile error rather than panicking if it
got bad input (that code is probably unreachable; I couldn't work
out how to hit it, but I've learned not to rely on my own ability to find errors).
589b54a2489560c1bd80Please rebase your changes so that they could pass on CI.
9560c1bd80a698e4a499After rebase, the changes are more substantial (a few new lints in the 20 versions jumped).
Nothing here should be controversial aside from maybe my choice to add a test case function that simply executes the derive macro on nested types. That needed a
dead_codesuppression. If I missed something intentional regarding the scoping of that, it's fairly easy to tweak.@ -9,3 +8,3 @@use syn::{DataEnum, Fields, FieldsNamed, FieldsUnnamed, Ident, Variant};pub fn generate(name: Ident, data_enum: DataEnum) -> TokenStream {use crate::type_length;Let me know if you'd prefer that I revert the use statement stuff. I have rustfmt set with the
imports_granularity=Crate,group_imports=StdExternalCrate, which I find to be really helpful,but it occasionally does rude things to other people's code.This needs to be rebased, as the other pull request was merged in.
a698e4a499toa80dd4670eRebased. I added error documentation for
try_from_fnandtry_mapto avoid a clippy warning there, but suppressed a panic docs warning onmap(which usesunwrap()onResult<_, Infallible>; something that clippy can't quite work out).