The sound distributed version control system

#682 Another round of Clippy fixes

Opened by Gaelan on May 14, 2022 Reviewing
Gaelan on May 14, 2022

Resubmitting this after the Nest ate the last one.

I’ve run cargo clippy --fix on everything, split into changes by lint type of ease of review. Some of the changes have dependencies (both Pijul-level and in some cases semantic) on each other - if you need me to redo a change with another change unrecorded so you can merge them separately, I can do that.

For Clippy fixes you’ve previously disagreed with, I’ve added #[allow(clippy::foo)] annotations so we won’t get warnings in the future.

Gaelan added a change on May 14, 2022
clippy fixes: use for loops for iterators (clippy::while_let_on_iterator) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 8, 2022
IKFZAKEUYS4IYV7EUM4SPRDSHRD7GTU75SLXIWOD4SYIFVIKOTCAC
Gaelan added a change on May 14, 2022
clippy fixes: use append instead of extend + drain (clippy::extend_with_drain) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 8, 2022
PMX7YELD2PU2EJAN5NFFN3JVF6AYTHR3UY6ASV6O2NAEARN35WKAC
Gaelan added a change on May 14, 2022
clippy fixes: use std::mem::take where appropriate (clippy::mem_replace_with_default) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 8, 2022
HNYCPLU74ZXH5HAADKRMAZADRCNWID3QAIEAFHCEMW2JJOIMABBQC
Gaelan added a change on May 14, 2022
clippy fixes: use .copied() where appropriate (clippy::map_clone) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 8, 2022
AUMJCJPJYQZCM5FMSIBYS3EJXRAUXEB2TT44YYGBV5WNWQNQHYMAC
Gaelan added a change on May 14, 2022
clippy fixes: don't pointlessly pass around values of type () (clippy::unit_arg) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
FUOR67YOW2MF3XA7H7BQRG6B5ALETTW3BRWHH7RU4R52I334DZFAC
Gaelan added a change on May 14, 2022
clippy fixes: remove pointless slicing (clippy::redundant_slicing) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
J4YWT5MHZ4FCOW563RSGDXWQCAVQGO7Y3D5MCGUMFAW2CA64FLFAC
Gaelan added a change on May 14, 2022
clippy fixes: use str::repeat (clippy::manual_str_repeat) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
JCKZJCIC6HWVEAXYASJN4ZJ3K5O6QS5REYURE55BRDX7IYRYC5RQC
Gaelan added a change on May 14, 2022
clippy fixes: simplify !(==) to != (clippy::nonminimal_bool) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
DCBFQWI23QZEZXF5GU2OUR2CWHV5W2VROSWJHGT3Q63DXF4T5LGAC
Gaelan added a change on May 14, 2022
clippy fixes: remove pointless calls to format!() (clippy::useless_format) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
BN5KOJ67UJGQH2MTGD322EUKETDY6272HCKK3NLEOWJCA2AB5NPAC
Gaelan added a change on May 14, 2022
clippy fixes: no need to pass an empty string to writeln!() (clippy::writeln_empty_string) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
X3YFRLLDYR6A7X4L55ZXZ7U7MXARVKBLAVDL7XP6XXIDM6DO4D5AC
Gaelan added a change on May 14, 2022
clippy fixes: simplify if/else returning boolean (clippy::needless_bool) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
JY2BWSXXRBJTTZCTMDDZSZPLJSM22SHM74JBHSJFVNRQUVZS65IAC
Gaelan added a change on May 14, 2022
clippy fixes: don't use ref in top-level let bindings (clippy::toplevel_ref_arg) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
QMEV3YYYTIBQ7WDK3U455WERKSZZSPQY5NWQE4I3TKU4YBHTEQUQC
Gaelan added a change on May 14, 2022
clippy fixes: prefer find() over filter().next() (clippy::filter_next) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
6WOV6SMESUKCD6NUWU5EFCJX3QMDQNT44X5C5ZL67QTNZOW5MFOAC
Gaelan added a change on May 14, 2022
clippy fixes: prefer is_empty() over len() (clippy::len_zero) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
UGQUX4O7SEL7H67WL5ZYDRTWQLH3QHBX6JB7FNMXT5MK24EIC54QC
Gaelan added a change on May 14, 2022
clippy fixes: prefer is_empty() over == "" (clippy::comparison_to_empty) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
YYEXUQCYK2O4YKSZXHRSXI54WDRFXPW4VB2RXPKIL5IQ3E3G22LAC
Gaelan added a change on May 14, 2022
clippy fixes: use .entry().or_insert() on HashMap (clippy::map_entry) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
MWFLXI2YKXQKF5PTW3B7AMJD4VTTZWGQ6WPPT2PVNHMPQSCFZFXAC
Gaelan added a change on May 14, 2022
clippy fixes: remove explicit () return type (clippy::unused_unit) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
P74WM2ADE6IAQP5ZZP3OTFYW6CSIUJOD2RQMA55JVF6GOUACAYCQC
Gaelan added a change on May 14, 2022
disable clippy style warnings in chardetng by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
EGG3V3546GN3MYXAJQOE26JRN277BHIUO2SGWV6LGEJOSKI2VGKQC
Gaelan added a change on May 14, 2022
silence clippy int_plus_one warning (pmeunier thinks it's clearer as is) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
CPTY5O5I45PIWQ67M6J2VI67NLE6U4WMR7UV6PWUKRQKJ5YQAFZAC
Gaelan added a change on May 14, 2022
clippy fixes: use implicit returns (clippy::needless_return) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
XBHCMTAJYPP7US5ZMPPVQUGJMZGZPA67N57ZD7DRADWZDBICWSYAC
Gaelan added a change on May 14, 2022
clippy fixes: replace else {if} with else if (clippy::collapsible_else_if) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 9, 2022
QLU6V3BSX63NM3JDKKFESDTPP3CETSN64AUQ7K3UZTMCYYCQV3SAC
Gaelan added a change on May 14, 2022
clippy fixes: remove pointless .clone() calls on Copy types (clippy::clone_on_copy) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 13, 2022
5U4HF4FLLJOSZJGOPYGYXKRSRDVI2II7HUCGBYKUG25Z2JF33K2AC
Gaelan added a change on May 14, 2022
clippy fixes: use Option::as_deref() (clippy::option_as_ref_deref) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 13, 2022
4KY4D5BPKWB4RIP6HKDQPO2NZMYLTJUYOEQM2J5MMEDUDCZNETWAC
Gaelan added a change on May 14, 2022
clippy fixes: remove pointless .into() calls (clippy::useless_conversion) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 13, 2022
4OFXTS6JFJODK3FH4LSIYL7BOHBFZIL2DE3ADB5DEXF6IRXQLDJQC
Gaelan added a change on May 14, 2022
clippy fixes: remove clone() calls on values not used again (clippy::redundant_clone) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 13, 2022
MIDW4ETVSENPHKSWRM6PWCV42PF2K7WGRGBNWLR4WSZIG5INQGFQC
Gaelan added a change on May 14, 2022
clippy fixes: use struct initializer shorthand syntax (clippy::redundant_field_names) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 13, 2022
QZ6GQGRHJ7RVHDMSXOZZCASN3LXJD7KRYV5RAWJ243DUOUW5QUCAC
Gaelan added a change on May 14, 2022
clippy fixes: remove pointless borrows (clippy::needless_borrow) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 13, 2022
GENK254EFWM4PQ4Q74QSPKCUHIY5W66HBVPA6BDKDWNIAM7T6PFQC
Gaelan added a change on May 14, 2022
clippy fixes: use Option::map() where appropriate (clippy::manual_map) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 13, 2022
F4HY7B5HXUHNF6A7SYQIB2ZKPJX7SI7JYQBHJQK6VWUNFKBWL5DQC
Gaelan added a change on May 14, 2022
clippy fixes: simplify return Ok(foo?) to return foo (clippy::needless_question_mark) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 13, 2022
MFELKINPWWZ34GTAYHBWWIVYV6TCIWP4ISX4KHS5JDY24AJEGKCQC
Gaelan added a change on May 14, 2022
clippy fixes: collapse nested if statements (clippy::collapsible_if) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 13, 2022
EAQE6QLHXR3VYRBJTKJJ4QD774RMSHX6EGRBFZISXBDREX7XN5TAC
Gaelan added a change on May 14, 2022
clippy fixes: pass char (not str) to string methods where appropriate (clippy::single_char_pattern) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 13, 2022
SKGTRN5EMUBCXEOBI3QDF42YO4PQGXIMENCDDXZEPZNBLD5Z6EUAC
Gaelan added a change on May 14, 2022
manually clean up contains() condition in vertex.rs by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 13, 2022
N7QIZMCZFGNNHYFNAH57TB3MVT3OMXG6NHW4BWEY6I3C32ARHUZQC
Gaelan added a change on May 14, 2022
clippy fixes: don't pointlessly wrap functions in closures (clippy::redundant_closure) by 3uGTfSxiPfZM9adJMcQLNHqMdb9m3ghhMAxFaFGdAmjJ, created on May 13, 2022
XJ6TOZXMBIWKG6RRPRXW4VCEMRQFFTFC755TOPYWBLTEGHWO4JRQC
pmeunier on February 22, 2023

Hi! Thanks for these patches. I’m usually a bit reluctant to applying patches from Clippy, since (1) I’m not confident enough that they never change the semantics and (2) I strongly disagree with a significant portion of Clippy’s definition of the “right” style, which I often find less readable than my own.

I always thought that Clippy’s best use was to experiment with warnings and possibly integrate them into Rustc in the future.

In this particular case, I don’t mind reviewing some of them, but you should add #IUH7IMWES3KQTHVWA5UNHAO7QWVCC5PQJ6VLK3RC3T4F2MS74P3AC to the ones that touch libpijul, which is Pijul’s way of saying that you read the CLA.

pmeunier added tag Reviewing on February 22, 2023
Gaelan on February 22, 2023

Apologies for the giant patch dump - in retrospect it may have been less than helpful.

I strongly disagree with a significant portion of Clippy’s definition of the “right” style, which I often find less readable than my own

Yeah, Clippy does have some questionable lints.

I’ve found enough of them are useful that it’s worth the time to keep cargo clippy happy (either by fixing the code or disabling lints), but it’s entirely reasonable to disagree.

In this particular case, I don’t mind reviewing some of them, but you should add #IUH7IMWES3KQTHVWA5UNHAO7QWVCC5PQJ6VLK3RC3T4F2MS74P3AC to the ones that touch libpijul, which is Pijul’s way of saying that you read the CLA.

I thought I did! Did I miss one?

pmeunier on February 22, 2023

I thought I did! Did I miss one?

Some do have it, others don’t. This could also be an error with the dependency minimisation algorithm. I’ll try to reproduce.

Gaelan on February 22, 2023

Don’t try too hard, it may well have been human error - if I recall correctly, my process for the dependency where necessary was rather haphazard.

In any case, it’s in my extra-dependencies now - I think I added it halfway through putting those patches together.

I’ll see about adding the rest now.