-
Notifications
You must be signed in to change notification settings - Fork 411
Replace arc.clone()
with Arc::clone
and reject the former in clippy (plus enforce clippy in tests)
#3851
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
Merged
wpaulino
merged 10 commits into
lightningdevkit:main
from
TheBlueMatt:2025-06-no-arc-clones
Jun 13, 2025
Merged
Replace arc.clone()
with Arc::clone
and reject the former in clippy (plus enforce clippy in tests)
#3851
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d89db75
Replace `Arc.clone()` syntax with `Arc::clone()` in net-tokio
TheBlueMatt ae51f25
Replace `Arc.clone()`s with `Arc::clone()` in background-processor
TheBlueMatt 040a372
Reject `Arc.clone()` syntax in favor of `Arc::clone`
TheBlueMatt 6f7e0c1
Allow some additional clippy lints that we want to keep in tests
TheBlueMatt 3a8863f
Address clippy lints in `lightning` test code
TheBlueMatt f46be2c
Address clippy lints in remaining tests
TheBlueMatt 6ff262f
Replace `Arc.clone()`s with `Arc::clone()` in BP tests
TheBlueMatt 50a75a1
Replace `Arc.clone()`s with `Arc::clone()` in remaining tests
TheBlueMatt 0774930
Fix log formatting in tests
TheBlueMatt 07590e4
Enforce clippy lints on test code in CI
TheBlueMatt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -1,99 +1,113 @@ | ||
#!/bin/sh | ||
set -e | ||
set -x | ||
RUSTFLAGS='-D warnings' cargo clippy -- \ | ||
`# Things where clippy is just wrong` \ | ||
-A clippy::unwrap-or-default \ | ||
`# Errors` \ | ||
-A clippy::erasing_op \ | ||
-A clippy::never_loop \ | ||
`# Warnings` \ | ||
-A renamed_and_removed_lints \ | ||
-A clippy::blocks_in_conditions \ | ||
-A clippy::borrow_deref_ref \ | ||
-A clippy::clone_on_copy \ | ||
-A clippy::collapsible_else_if \ | ||
-A clippy::collapsible_if \ | ||
-A clippy::collapsible_match \ | ||
-A clippy::comparison_chain \ | ||
-A clippy::doc_lazy_continuation \ | ||
-A clippy::drain_collect \ | ||
-A clippy::drop_non_drop \ | ||
-A clippy::enum_variant_names \ | ||
-A clippy::explicit_auto_deref \ | ||
-A clippy::extra_unused_lifetimes \ | ||
-A clippy::for_kv_map \ | ||
-A clippy::from_over_into \ | ||
-A clippy::get_first \ | ||
-A clippy::identity_op \ | ||
-A clippy::if_same_then_else \ | ||
-A clippy::inconsistent_digit_grouping \ | ||
-A clippy::iter_kv_map \ | ||
-A clippy::iter_skip_next \ | ||
-A clippy::large_enum_variant \ | ||
-A clippy::legacy_numeric_constants \ | ||
-A clippy::len_without_is_empty \ | ||
-A clippy::len_zero \ | ||
-A clippy::let_and_return \ | ||
-A clippy::manual_div_ceil `# to be removed once we hit MSRV 1.73.0` \ | ||
-A clippy::manual_filter \ | ||
-A clippy::manual_map \ | ||
-A clippy::manual_memcpy \ | ||
-A clippy::manual_inspect \ | ||
-A clippy::manual_range_contains \ | ||
-A clippy::manual_range_patterns \ | ||
-A clippy::manual_saturating_arithmetic \ | ||
-A clippy::manual_strip \ | ||
-A clippy::map_clone \ | ||
-A clippy::map_flatten \ | ||
-A clippy::match_like_matches_macro \ | ||
-A clippy::match_ref_pats \ | ||
-A clippy::multiple_bound_locations \ | ||
-A clippy::mut_mutex_lock \ | ||
-A clippy::needless_bool \ | ||
-A clippy::needless_borrow \ | ||
-A clippy::needless_borrowed_reference \ | ||
-A clippy::needless_borrows_for_generic_args \ | ||
-A clippy::needless_lifetimes \ | ||
-A clippy::needless_question_mark \ | ||
-A clippy::needless_range_loop \ | ||
-A clippy::needless_return \ | ||
-A clippy::new_without_default \ | ||
-A clippy::non_minimal_cfg \ | ||
-A clippy::op_ref \ | ||
-A clippy::option_as_ref_deref \ | ||
-A clippy::option_map_or_none \ | ||
-A clippy::option_map_unit_fn \ | ||
-A clippy::precedence \ | ||
-A clippy::ptr_arg \ | ||
-A clippy::question_mark \ | ||
-A clippy::readonly_write_lock \ | ||
-A clippy::redundant_closure \ | ||
-A clippy::redundant_field_names \ | ||
-A clippy::redundant_guards \ | ||
-A clippy::redundant_pattern_matching \ | ||
-A clippy::redundant_slicing \ | ||
-A clippy::redundant_static_lifetimes \ | ||
-A clippy::result_large_err \ | ||
-A clippy::result_unit_err \ | ||
-A clippy::search_is_some \ | ||
-A clippy::single_char_pattern \ | ||
-A clippy::single_match \ | ||
-A clippy::slow_vector_initialization \ | ||
-A clippy::tabs_in_doc_comments \ | ||
-A clippy::to_string_in_format_args \ | ||
-A clippy::too_many_arguments \ | ||
-A clippy::toplevel_ref_arg \ | ||
-A clippy::type_complexity \ | ||
-A clippy::unnecessary_cast \ | ||
-A clippy::unnecessary_get_then_check \ | ||
-A clippy::unnecessary_lazy_evaluations \ | ||
-A clippy::unnecessary_mut_passed \ | ||
-A clippy::unnecessary_sort_by \ | ||
-A clippy::unnecessary_to_owned \ | ||
-A clippy::unnecessary_unwrap \ | ||
-A clippy::unused_unit \ | ||
-A clippy::useless_conversion \ | ||
-A clippy::unnecessary_map_or `# to be removed once we hit MSRV 1.70` \ | ||
-A clippy::manual_repeat_n `# to be removed once we hit MSRV 1.86` \ | ||
-A clippy::io_other_error `# to be removed once we hit MSRV 1.74` | ||
|
||
CLIPPY() { | ||
# shellcheck disable=SC2086 | ||
RUSTFLAGS='-D warnings' cargo clippy $1 -- $2 \ | ||
`# Things clippy defaults to allowing but we should avoid` \ | ||
-D clippy::clone_on_ref_ptr \ | ||
`# Things where clippy is just wrong` \ | ||
-A clippy::unwrap-or-default \ | ||
-A clippy::upper_case_acronyms \ | ||
`# Things where we do odd stuff on purpose ` \ | ||
-A clippy::unusual_byte_groupings \ | ||
-A clippy::unit_arg \ | ||
`# Errors` \ | ||
-A clippy::erasing_op \ | ||
-A clippy::never_loop \ | ||
`# Warnings` \ | ||
-A renamed_and_removed_lints \ | ||
-A clippy::blocks_in_conditions \ | ||
-A clippy::borrow_deref_ref \ | ||
-A clippy::clone_on_copy \ | ||
-A clippy::collapsible_else_if \ | ||
-A clippy::collapsible_if \ | ||
-A clippy::collapsible_match \ | ||
-A clippy::comparison_chain \ | ||
-A clippy::doc_lazy_continuation \ | ||
-A clippy::drain_collect \ | ||
-A clippy::drop_non_drop \ | ||
-A clippy::enum_variant_names \ | ||
-A clippy::explicit_auto_deref \ | ||
-A clippy::extra_unused_lifetimes \ | ||
-A clippy::for_kv_map \ | ||
-A clippy::from_over_into \ | ||
-A clippy::get_first \ | ||
-A clippy::identity_op \ | ||
-A clippy::if_same_then_else \ | ||
-A clippy::inconsistent_digit_grouping \ | ||
-A clippy::iter_kv_map \ | ||
-A clippy::iter_skip_next \ | ||
-A clippy::large_enum_variant \ | ||
-A clippy::legacy_numeric_constants \ | ||
-A clippy::len_without_is_empty \ | ||
-A clippy::len_zero \ | ||
-A clippy::let_and_return \ | ||
-A clippy::manual_div_ceil `# to be removed once we hit MSRV 1.73.0` \ | ||
-A clippy::manual_filter \ | ||
-A clippy::manual_map \ | ||
-A clippy::manual_memcpy \ | ||
-A clippy::manual_inspect \ | ||
-A clippy::manual_range_contains \ | ||
-A clippy::manual_range_patterns \ | ||
-A clippy::manual_saturating_arithmetic \ | ||
-A clippy::manual_strip \ | ||
-A clippy::map_clone \ | ||
-A clippy::map_flatten \ | ||
-A clippy::match_like_matches_macro \ | ||
-A clippy::match_ref_pats \ | ||
-A clippy::multiple_bound_locations \ | ||
-A clippy::mut_mutex_lock \ | ||
-A clippy::needless_bool \ | ||
-A clippy::needless_borrow \ | ||
-A clippy::needless_borrowed_reference \ | ||
-A clippy::needless_borrows_for_generic_args \ | ||
-A clippy::needless_lifetimes \ | ||
-A clippy::needless_question_mark \ | ||
-A clippy::needless_range_loop \ | ||
-A clippy::needless_return \ | ||
-A clippy::new_without_default \ | ||
-A clippy::non_minimal_cfg \ | ||
-A clippy::op_ref \ | ||
-A clippy::option_as_ref_deref \ | ||
-A clippy::option_map_or_none \ | ||
-A clippy::option_map_unit_fn \ | ||
-A clippy::precedence \ | ||
-A clippy::ptr_arg \ | ||
-A clippy::question_mark \ | ||
-A clippy::readonly_write_lock \ | ||
-A clippy::redundant_closure \ | ||
-A clippy::redundant_field_names \ | ||
-A clippy::redundant_guards \ | ||
-A clippy::redundant_pattern_matching \ | ||
-A clippy::redundant_slicing \ | ||
-A clippy::redundant_static_lifetimes \ | ||
-A clippy::result_large_err \ | ||
-A clippy::result_unit_err \ | ||
-A clippy::search_is_some \ | ||
-A clippy::single_char_pattern \ | ||
-A clippy::single_match \ | ||
-A clippy::slow_vector_initialization \ | ||
-A clippy::tabs_in_doc_comments \ | ||
-A clippy::to_string_in_format_args \ | ||
-A clippy::too_many_arguments \ | ||
-A clippy::toplevel_ref_arg \ | ||
-A clippy::type_complexity \ | ||
-A clippy::unnecessary_cast \ | ||
-A clippy::unnecessary_get_then_check \ | ||
-A clippy::unnecessary_lazy_evaluations \ | ||
-A clippy::unnecessary_mut_passed \ | ||
-A clippy::unnecessary_sort_by \ | ||
-A clippy::unnecessary_to_owned \ | ||
-A clippy::unnecessary_unwrap \ | ||
-A clippy::unused_unit \ | ||
-A clippy::useless_conversion \ | ||
-A clippy::unnecessary_map_or `# to be removed once we hit MSRV 1.70` \ | ||
-A clippy::manual_repeat_n `# to be removed once we hit MSRV 1.86` \ | ||
-A clippy::io_other_error `# to be removed once we hit MSRV 1.74` | ||
} | ||
|
||
CLIPPY | ||
# We allow some additional warnings in tests which we should fix, but which aren't currently a priority | ||
CLIPPY --tests "-A clippy::bool_assert_comparison -A clippy::assertions_on_constants -A clippy::needless-late-init -A clippy::field_reassign_with_default -A clippy::unnecessary_literal_unwrap -A clippy::useless_vec" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Not sure if we shouldn't just fix it instead of disabling the check, but not going to block this because of 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.
The lack of quotes is deliberate, we need to pass multiple things to
clippy
via one argument.