Skip to content

Commit ed16b5f

Browse files
authored
Merge pull request #3851 from TheBlueMatt/2025-06-no-arc-clones
Replace `arc.clone()` with `Arc::clone` and reject the former in clippy (plus enforce clippy in tests)
2 parents 4aa1335 + 07590e4 commit ed16b5f

File tree

28 files changed

+435
-432
lines changed

28 files changed

+435
-432
lines changed

ci/check-lint.sh

Lines changed: 110 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,113 @@
11
#!/bin/sh
22
set -e
33
set -x
4-
RUSTFLAGS='-D warnings' cargo clippy -- \
5-
`# Things where clippy is just wrong` \
6-
-A clippy::unwrap-or-default \
7-
`# Errors` \
8-
-A clippy::erasing_op \
9-
-A clippy::never_loop \
10-
`# Warnings` \
11-
-A renamed_and_removed_lints \
12-
-A clippy::blocks_in_conditions \
13-
-A clippy::borrow_deref_ref \
14-
-A clippy::clone_on_copy \
15-
-A clippy::collapsible_else_if \
16-
-A clippy::collapsible_if \
17-
-A clippy::collapsible_match \
18-
-A clippy::comparison_chain \
19-
-A clippy::doc_lazy_continuation \
20-
-A clippy::drain_collect \
21-
-A clippy::drop_non_drop \
22-
-A clippy::enum_variant_names \
23-
-A clippy::explicit_auto_deref \
24-
-A clippy::extra_unused_lifetimes \
25-
-A clippy::for_kv_map \
26-
-A clippy::from_over_into \
27-
-A clippy::get_first \
28-
-A clippy::identity_op \
29-
-A clippy::if_same_then_else \
30-
-A clippy::inconsistent_digit_grouping \
31-
-A clippy::iter_kv_map \
32-
-A clippy::iter_skip_next \
33-
-A clippy::large_enum_variant \
34-
-A clippy::legacy_numeric_constants \
35-
-A clippy::len_without_is_empty \
36-
-A clippy::len_zero \
37-
-A clippy::let_and_return \
38-
-A clippy::manual_div_ceil `# to be removed once we hit MSRV 1.73.0` \
39-
-A clippy::manual_filter \
40-
-A clippy::manual_map \
41-
-A clippy::manual_memcpy \
42-
-A clippy::manual_inspect \
43-
-A clippy::manual_range_contains \
44-
-A clippy::manual_range_patterns \
45-
-A clippy::manual_saturating_arithmetic \
46-
-A clippy::manual_strip \
47-
-A clippy::map_clone \
48-
-A clippy::map_flatten \
49-
-A clippy::match_like_matches_macro \
50-
-A clippy::match_ref_pats \
51-
-A clippy::multiple_bound_locations \
52-
-A clippy::mut_mutex_lock \
53-
-A clippy::needless_bool \
54-
-A clippy::needless_borrow \
55-
-A clippy::needless_borrowed_reference \
56-
-A clippy::needless_borrows_for_generic_args \
57-
-A clippy::needless_lifetimes \
58-
-A clippy::needless_question_mark \
59-
-A clippy::needless_range_loop \
60-
-A clippy::needless_return \
61-
-A clippy::new_without_default \
62-
-A clippy::non_minimal_cfg \
63-
-A clippy::op_ref \
64-
-A clippy::option_as_ref_deref \
65-
-A clippy::option_map_or_none \
66-
-A clippy::option_map_unit_fn \
67-
-A clippy::precedence \
68-
-A clippy::ptr_arg \
69-
-A clippy::question_mark \
70-
-A clippy::readonly_write_lock \
71-
-A clippy::redundant_closure \
72-
-A clippy::redundant_field_names \
73-
-A clippy::redundant_guards \
74-
-A clippy::redundant_pattern_matching \
75-
-A clippy::redundant_slicing \
76-
-A clippy::redundant_static_lifetimes \
77-
-A clippy::result_large_err \
78-
-A clippy::result_unit_err \
79-
-A clippy::search_is_some \
80-
-A clippy::single_char_pattern \
81-
-A clippy::single_match \
82-
-A clippy::slow_vector_initialization \
83-
-A clippy::tabs_in_doc_comments \
84-
-A clippy::to_string_in_format_args \
85-
-A clippy::too_many_arguments \
86-
-A clippy::toplevel_ref_arg \
87-
-A clippy::type_complexity \
88-
-A clippy::unnecessary_cast \
89-
-A clippy::unnecessary_get_then_check \
90-
-A clippy::unnecessary_lazy_evaluations \
91-
-A clippy::unnecessary_mut_passed \
92-
-A clippy::unnecessary_sort_by \
93-
-A clippy::unnecessary_to_owned \
94-
-A clippy::unnecessary_unwrap \
95-
-A clippy::unused_unit \
96-
-A clippy::useless_conversion \
97-
-A clippy::unnecessary_map_or `# to be removed once we hit MSRV 1.70` \
98-
-A clippy::manual_repeat_n `# to be removed once we hit MSRV 1.86` \
99-
-A clippy::io_other_error `# to be removed once we hit MSRV 1.74`
4+
5+
CLIPPY() {
6+
# shellcheck disable=SC2086
7+
RUSTFLAGS='-D warnings' cargo clippy $1 -- $2 \
8+
`# Things clippy defaults to allowing but we should avoid` \
9+
-D clippy::clone_on_ref_ptr \
10+
`# Things where clippy is just wrong` \
11+
-A clippy::unwrap-or-default \
12+
-A clippy::upper_case_acronyms \
13+
`# Things where we do odd stuff on purpose ` \
14+
-A clippy::unusual_byte_groupings \
15+
-A clippy::unit_arg \
16+
`# Errors` \
17+
-A clippy::erasing_op \
18+
-A clippy::never_loop \
19+
`# Warnings` \
20+
-A renamed_and_removed_lints \
21+
-A clippy::blocks_in_conditions \
22+
-A clippy::borrow_deref_ref \
23+
-A clippy::clone_on_copy \
24+
-A clippy::collapsible_else_if \
25+
-A clippy::collapsible_if \
26+
-A clippy::collapsible_match \
27+
-A clippy::comparison_chain \
28+
-A clippy::doc_lazy_continuation \
29+
-A clippy::drain_collect \
30+
-A clippy::drop_non_drop \
31+
-A clippy::enum_variant_names \
32+
-A clippy::explicit_auto_deref \
33+
-A clippy::extra_unused_lifetimes \
34+
-A clippy::for_kv_map \
35+
-A clippy::from_over_into \
36+
-A clippy::get_first \
37+
-A clippy::identity_op \
38+
-A clippy::if_same_then_else \
39+
-A clippy::inconsistent_digit_grouping \
40+
-A clippy::iter_kv_map \
41+
-A clippy::iter_skip_next \
42+
-A clippy::large_enum_variant \
43+
-A clippy::legacy_numeric_constants \
44+
-A clippy::len_without_is_empty \
45+
-A clippy::len_zero \
46+
-A clippy::let_and_return \
47+
-A clippy::manual_div_ceil `# to be removed once we hit MSRV 1.73.0` \
48+
-A clippy::manual_filter \
49+
-A clippy::manual_map \
50+
-A clippy::manual_memcpy \
51+
-A clippy::manual_inspect \
52+
-A clippy::manual_range_contains \
53+
-A clippy::manual_range_patterns \
54+
-A clippy::manual_saturating_arithmetic \
55+
-A clippy::manual_strip \
56+
-A clippy::map_clone \
57+
-A clippy::map_flatten \
58+
-A clippy::match_like_matches_macro \
59+
-A clippy::match_ref_pats \
60+
-A clippy::multiple_bound_locations \
61+
-A clippy::mut_mutex_lock \
62+
-A clippy::needless_bool \
63+
-A clippy::needless_borrow \
64+
-A clippy::needless_borrowed_reference \
65+
-A clippy::needless_borrows_for_generic_args \
66+
-A clippy::needless_lifetimes \
67+
-A clippy::needless_question_mark \
68+
-A clippy::needless_range_loop \
69+
-A clippy::needless_return \
70+
-A clippy::new_without_default \
71+
-A clippy::non_minimal_cfg \
72+
-A clippy::op_ref \
73+
-A clippy::option_as_ref_deref \
74+
-A clippy::option_map_or_none \
75+
-A clippy::option_map_unit_fn \
76+
-A clippy::precedence \
77+
-A clippy::ptr_arg \
78+
-A clippy::question_mark \
79+
-A clippy::readonly_write_lock \
80+
-A clippy::redundant_closure \
81+
-A clippy::redundant_field_names \
82+
-A clippy::redundant_guards \
83+
-A clippy::redundant_pattern_matching \
84+
-A clippy::redundant_slicing \
85+
-A clippy::redundant_static_lifetimes \
86+
-A clippy::result_large_err \
87+
-A clippy::result_unit_err \
88+
-A clippy::search_is_some \
89+
-A clippy::single_char_pattern \
90+
-A clippy::single_match \
91+
-A clippy::slow_vector_initialization \
92+
-A clippy::tabs_in_doc_comments \
93+
-A clippy::to_string_in_format_args \
94+
-A clippy::too_many_arguments \
95+
-A clippy::toplevel_ref_arg \
96+
-A clippy::type_complexity \
97+
-A clippy::unnecessary_cast \
98+
-A clippy::unnecessary_get_then_check \
99+
-A clippy::unnecessary_lazy_evaluations \
100+
-A clippy::unnecessary_mut_passed \
101+
-A clippy::unnecessary_sort_by \
102+
-A clippy::unnecessary_to_owned \
103+
-A clippy::unnecessary_unwrap \
104+
-A clippy::unused_unit \
105+
-A clippy::useless_conversion \
106+
-A clippy::unnecessary_map_or `# to be removed once we hit MSRV 1.70` \
107+
-A clippy::manual_repeat_n `# to be removed once we hit MSRV 1.86` \
108+
-A clippy::io_other_error `# to be removed once we hit MSRV 1.74`
109+
}
110+
111+
CLIPPY
112+
# We allow some additional warnings in tests which we should fix, but which aren't currently a priority
113+
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"

0 commit comments

Comments
 (0)