Skip to content

Commit 6d07e0a

Browse files
committed
Update clippy ignore rules
1 parent 436fb05 commit 6d07e0a

File tree

21 files changed

+126
-137
lines changed

21 files changed

+126
-137
lines changed

.github/workflows/build.yml

Lines changed: 85 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -251,102 +251,94 @@ jobs:
251251
rustup component add clippy
252252
- name: Run default clippy linting
253253
run: |
254-
cargo clippy -- \
254+
RUSTFLAGS='-D warnings' cargo clippy -- \
255255
`# Errors` \
256-
-Aclippy::erasing_op \
257-
-Aclippy::never_loop \
256+
-A clippy::erasing_op \
257+
-A clippy::never_loop \
258258
`# Warnings` \
259259
-A renamed_and_removed_lints \
260-
-Aclippy::assign_op_pattern \
261-
-Aclippy::assigning_clones \
262-
-Aclippy::bind_instead_of_map \
263-
-Aclippy::blocks_in_conditions \
264-
-Aclippy::bool_comparison \
265-
-Aclippy::borrow_deref_ref \
266-
-Aclippy::clone_on_copy \
267-
-Aclippy::collapsible_else_if \
268-
-Aclippy::collapsible_if \
269-
-Aclippy::collapsible_match \
270-
-Aclippy::comparison_chain \
271-
-Aclippy::drain_collect \
272-
-Aclippy::drop_non_drop \
273-
-Aclippy::enum_variant_names \
274-
-Aclippy::explicit_auto_deref \
275-
-Aclippy::extra_unused_lifetimes \
276-
-Aclippy::for_kv_map \
277-
-Aclippy::from_over_into \
278-
-Aclippy::get_first \
279-
-Aclippy::identity_op \
280-
-Aclippy::if_same_then_else \
281-
-Aclippy::inconsistent_digit_grouping \
282-
-Aclippy::iter_kv_map \
283-
-Aclippy::iter_skip_next \
284-
-Aclippy::large_enum_variant \
285-
-Aclippy::legacy_numeric_constants \
286-
-Aclippy::len_without_is_empty \
287-
-Aclippy::len_zero \
288-
-Aclippy::let_and_return \
289-
-Aclippy::manual_filter \
290-
-Aclippy::manual_map \
291-
-Aclippy::manual_memcpy \
292-
-Aclippy::manual_range_contains \
293-
-Aclippy::manual_range_patterns \
294-
-Aclippy::manual_saturating_arithmetic \
295-
-Aclippy::manual_strip \
296-
-Aclippy::map_clone \
297-
-Aclippy::map_flatten \
298-
-Aclippy::match_like_matches_macro \
299-
-Aclippy::match_ref_pats \
300-
-Aclippy::mut_mutex_lock \
301-
-Aclippy::needless_bool \
302-
-Aclippy::needless_borrow \
303-
-Aclippy::needless_borrowed_reference \
304-
-Aclippy::needless_borrows_for_generic_args \
305-
-Aclippy::needless_lifetimes \
306-
-Aclippy::needless_question_mark \
307-
-Aclippy::needless_range_loop \
308-
-Aclippy::needless_return \
309-
-Aclippy::new_without_default \
310-
-Aclippy::non_minimal_cfg \
311-
-Aclippy::option_as_ref_deref \
312-
-Aclippy::option_map_or_none \
313-
-Aclippy::option_map_unit_fn \
314-
-Aclippy::precedence \
315-
-Aclippy::ptr_arg \
316-
-Aclippy::question_mark \
317-
-Aclippy::readonly_write_lock \
318-
-Aclippy::redundant_closure \
319-
-Aclippy::redundant_field_names \
320-
-Aclippy::redundant_guards \
321-
-Aclippy::redundant_pattern_matching \
322-
-Aclippy::redundant_slicing \
323-
-Aclippy::redundant_static_lifetimes \
324-
-Aclippy::result_large_err \
325-
-Aclippy::result_unit_err \
326-
-Aclippy::search_is_some \
327-
-Aclippy::single_char_pattern \
328-
-Aclippy::single_match \
329-
-Aclippy::slow_vector_initialization \
330-
-Aclippy::tabs_in_doc_comments \
331-
-Aclippy::to_string_in_format_args \
332-
-Aclippy::too_many_arguments \
333-
-Aclippy::toplevel_ref_arg \
334-
-Aclippy::type_complexity \
335-
-Aclippy::unnecessary_cast \
336-
-Aclippy::unnecessary_get_then_check \
337-
-Aclippy::unnecessary_lazy_evaluations \
338-
-Aclippy::unnecessary_mut_passed \
339-
-Aclippy::unnecessary_sort_by \
340-
-Aclippy::unnecessary_to_owned \
341-
-Aclippy::unnecessary_unwrap \
342-
-Aclippy::unused_unit \
343-
-Aclippy::unwrap_or_default \
344-
-Aclippy::useless_conversion \
345-
-Aclippy::useless_format \
346-
-Aclippy::vec_init_then_push \
347-
-Aclippy::while_let_on_iterator \
348-
-Aclippy::wrong_self_convention \
349-
-Dclippy::try_err
260+
-A clippy::blocks_in_conditions \
261+
-A clippy::borrow_deref_ref \
262+
-A clippy::clone_on_copy \
263+
-A clippy::collapsible_else_if \
264+
-A clippy::collapsible_if \
265+
-A clippy::collapsible_match \
266+
-A clippy::comparison_chain \
267+
-A clippy::drain_collect \
268+
-A clippy::drop_non_drop \
269+
-A clippy::enum_variant_names \
270+
-A clippy::explicit_auto_deref \
271+
-A clippy::extra_unused_lifetimes \
272+
-A clippy::for_kv_map \
273+
-A clippy::from_over_into \
274+
-A clippy::get_first \
275+
-A clippy::identity_op \
276+
-A clippy::if_same_then_else \
277+
-A clippy::inconsistent_digit_grouping \
278+
-A clippy::iter_kv_map \
279+
-A clippy::iter_skip_next \
280+
-A clippy::large_enum_variant \
281+
-A clippy::legacy_numeric_constants \
282+
-A clippy::len_without_is_empty \
283+
-A clippy::len_zero \
284+
-A clippy::let_and_return \
285+
-A clippy::manual_filter \
286+
-A clippy::manual_map \
287+
-A clippy::manual_memcpy \
288+
-A clippy::manual_range_contains \
289+
-A clippy::manual_range_patterns \
290+
-A clippy::manual_saturating_arithmetic \
291+
-A clippy::manual_strip \
292+
-A clippy::map_clone \
293+
-A clippy::map_flatten \
294+
-A clippy::match_like_matches_macro \
295+
-A clippy::match_ref_pats \
296+
-A clippy::multiple_bound_locations \
297+
-A clippy::mut_mutex_lock \
298+
-A clippy::needless_bool \
299+
-A clippy::needless_borrow \
300+
-A clippy::needless_borrowed_reference \
301+
-A clippy::needless_borrows_for_generic_args \
302+
-A clippy::needless_lifetimes \
303+
-A clippy::needless_question_mark \
304+
-A clippy::needless_range_loop \
305+
-A clippy::needless_return \
306+
-A clippy::new_without_default \
307+
-A clippy::non_minimal_cfg \
308+
-A clippy::op_ref \
309+
-A clippy::option_as_ref_deref \
310+
-A clippy::option_map_or_none \
311+
-A clippy::option_map_unit_fn \
312+
-A clippy::precedence \
313+
-A clippy::ptr_arg \
314+
-A clippy::question_mark \
315+
-A clippy::readonly_write_lock \
316+
-A clippy::redundant_closure \
317+
-A clippy::redundant_field_names \
318+
-A clippy::redundant_guards \
319+
-A clippy::redundant_pattern_matching \
320+
-A clippy::redundant_slicing \
321+
-A clippy::redundant_static_lifetimes \
322+
-A clippy::result_large_err \
323+
-A clippy::result_unit_err \
324+
-A clippy::search_is_some \
325+
-A clippy::single_char_pattern \
326+
-A clippy::single_match \
327+
-A clippy::slow_vector_initialization \
328+
-A clippy::tabs_in_doc_comments \
329+
-A clippy::to_string_in_format_args \
330+
-A clippy::too_many_arguments \
331+
-A clippy::toplevel_ref_arg \
332+
-A clippy::type_complexity \
333+
-A clippy::unnecessary_cast \
334+
-A clippy::unnecessary_get_then_check \
335+
-A clippy::unnecessary_lazy_evaluations \
336+
-A clippy::unnecessary_mut_passed \
337+
-A clippy::unnecessary_sort_by \
338+
-A clippy::unnecessary_to_owned \
339+
-A clippy::unnecessary_unwrap \
340+
-A clippy::unused_unit \
341+
-A clippy::useless_conversion
350342
351343
rustfmt:
352344
runs-on: ubuntu-latest

lightning-rapid-gossip-sync/src/processing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ where
176176
.and_then(|node| node.announcement_info.as_ref())
177177
.map(|info| {
178178
synthetic_node_announcement.features = info.features().clone();
179-
synthetic_node_announcement.rgb = info.rgb().clone();
179+
synthetic_node_announcement.rgb.clone_from(&info.rgb());
180180
synthetic_node_announcement.alias = info.alias().clone();
181181
synthetic_node_announcement.addresses = info.addresses().to_vec();
182182
});

lightning/src/chain/onchaintx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ impl<ChannelSigner: EcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
761761
for outpoint in req.outpoints() {
762762
log_info!(logger, " Outpoint {}", outpoint);
763763
}
764-
self.locktimed_packages.entry(package_locktime).or_insert(Vec::new()).push(req);
764+
self.locktimed_packages.entry(package_locktime).or_default().push(req);
765765
continue;
766766
}
767767

lightning/src/chain/package.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,8 +1033,7 @@ impl PackageTemplate {
10331033

10341034
pub (crate) fn build_package(txid: Txid, vout: u32, input_solving_data: PackageSolvingData, soonest_conf_deadline: u32, height_original: u32) -> Self {
10351035
let (malleability, aggregable) = PackageSolvingData::map_output_type_flags(&input_solving_data);
1036-
let mut inputs = Vec::with_capacity(1);
1037-
inputs.push((BitcoinOutPoint { txid, vout }, input_solving_data));
1036+
let inputs = vec![(BitcoinOutPoint { txid, vout }, input_solving_data)];
10381037
PackageTemplate {
10391038
inputs,
10401039
malleability,

lightning/src/crypto/chacha20.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ mod real_chacha {
176176
) {
177177
let block = ChaCha20::get_single_block(key, nonce);
178178
for i in 0..bytes.len() {
179-
bytes[i] = block[i] ^ bytes[i];
179+
bytes[i] ^= block[i];
180180
}
181181
}
182182

lightning/src/crypto/chacha20poly1305rfc.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ mod real_chachapoly {
5959

6060
pub fn encrypt(&mut self, input: &[u8], output: &mut [u8], out_tag: &mut [u8]) {
6161
assert!(input.len() == output.len());
62-
assert!(self.finished == false);
62+
assert!(!self.finished);
6363
self.cipher.process(input, output);
6464
self.data_len += input.len();
6565
self.mac.input(output);
@@ -78,7 +78,7 @@ mod real_chachapoly {
7878
// Encrypt `input_output` in-place. To finish and calculate the tag, use `finish_and_get_tag`
7979
// below.
8080
pub(in super::super) fn encrypt_in_place(&mut self, input_output: &mut [u8]) {
81-
debug_assert!(self.finished == false);
81+
debug_assert!(!self.finished);
8282
self.cipher.process_in_place(input_output);
8383
self.data_len += input_output.len();
8484
self.mac.input(input_output);
@@ -87,7 +87,7 @@ mod real_chachapoly {
8787
// If we were previously encrypting with `encrypt_in_place`, this method can be used to finish
8888
// encrypting and calculate the tag.
8989
pub(in super::super) fn finish_and_get_tag(&mut self, out_tag: &mut [u8]) {
90-
debug_assert!(self.finished == false);
90+
debug_assert!(!self.finished);
9191
ChaCha20Poly1305RFC::pad_mac_16(&mut self.mac, self.data_len);
9292
self.finished = true;
9393
self.mac.input(&self.aad_len.to_le_bytes());
@@ -100,7 +100,7 @@ mod real_chachapoly {
100100
/// this decryption is *variable time*.
101101
pub fn variable_time_decrypt(&mut self, input: &[u8], output: &mut [u8], tag: &[u8]) -> Result<(), ()> {
102102
assert!(input.len() == output.len());
103-
assert!(self.finished == false);
103+
assert!(!self.finished);
104104

105105
self.finished = true;
106106

@@ -131,7 +131,7 @@ mod real_chachapoly {
131131
///
132132
/// Should never be `pub` because the public API should always enforce tag checking.
133133
pub(in super::super) fn decrypt_in_place(&mut self, input_output: &mut [u8]) {
134-
debug_assert!(self.finished == false);
134+
debug_assert!(!self.finished);
135135
self.mac.input(input_output);
136136
self.data_len += input_output.len();
137137
self.cipher.process_in_place(input_output);
@@ -140,7 +140,7 @@ mod real_chachapoly {
140140
/// If we were previously decrypting with `just_decrypt_in_place`, this method must be used
141141
/// to check the tag. Returns whether or not the tag is valid.
142142
pub(in super::super) fn finish_and_check_tag(&mut self, tag: &[u8]) -> bool {
143-
debug_assert!(self.finished == false);
143+
debug_assert!(!self.finished);
144144
self.finished = true;
145145
ChaCha20Poly1305RFC::pad_mac_16(&mut self.mac, self.data_len);
146146
self.mac.input(&self.aad_len.to_le_bytes());

lightning/src/crypto/poly1305.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl Poly1305 {
8282
d2 += c as u64; c = (d2 >> 26) as u32; h2 = d2 as u32 & 0x3ffffff;
8383
d3 += c as u64; c = (d3 >> 26) as u32; h3 = d3 as u32 & 0x3ffffff;
8484
d4 += c as u64; c = (d4 >> 26) as u32; h4 = d4 as u32 & 0x3ffffff;
85-
h0 += c * 5; c = h0 >> 26; h0 = h0 & 0x3ffffff;
85+
h0 += c * 5; c = h0 >> 26; h0 &= 0x3ffffff;
8686
h1 += c;
8787

8888
self.h[0] = h0;
@@ -111,11 +111,11 @@ impl Poly1305 {
111111
let mut h4 = self.h[4];
112112

113113
let mut c : u32;
114-
c = h1 >> 26; h1 = h1 & 0x3ffffff;
115-
h2 += c; c = h2 >> 26; h2 = h2 & 0x3ffffff;
116-
h3 += c; c = h3 >> 26; h3 = h3 & 0x3ffffff;
117-
h4 += c; c = h4 >> 26; h4 = h4 & 0x3ffffff;
118-
h0 += c * 5; c = h0 >> 26; h0 = h0 & 0x3ffffff;
114+
c = h1 >> 26; h1 &= 0x3ffffff;
115+
h2 += c; c = h2 >> 26; h2 &= 0x3ffffff;
116+
h3 += c; c = h3 >> 26; h3 &= 0x3ffffff;
117+
h4 += c; c = h4 >> 26; h4 &= 0x3ffffff;
118+
h0 += c * 5; c = h0 >> 26; h0 &= 0x3ffffff;
119119
h1 += c;
120120

121121
// compute h + -p

lightning/src/events/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,7 @@ pub enum Event {
12411241
///
12421242
/// This field will be `None` for objects serialized prior to LDK 0.0.117.
12431243
channel_capacity_sats: Option<u64>,
1244+
12441245
/// The original channel funding TXO; this helps checking for the existence and confirmation
12451246
/// status of the closing tx.
12461247
/// Note that for instances serialized in v0.0.119 or prior this will be missing (None).
@@ -2004,7 +2005,7 @@ impl MaybeReadable for Event {
20042005
payment_hash,
20052006
purpose: _init_tlv_based_struct_field!(purpose, upgradable_required),
20062007
amount_msat,
2007-
htlcs: htlcs.unwrap_or(vec![]),
2008+
htlcs: htlcs.unwrap_or_default(),
20082009
sender_intended_total_msat,
20092010
onion_fields,
20102011
}))

lightning/src/ln/chan_utils.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,12 @@ pub fn build_commitment_secret(commitment_seed: &[u8; 32], idx: u64) -> [u8; 32]
221221
/// Build a closing transaction
222222
pub fn build_closing_transaction(to_holder_value_sat: Amount, to_counterparty_value_sat: Amount, to_holder_script: ScriptBuf, to_counterparty_script: ScriptBuf, funding_outpoint: OutPoint) -> Transaction {
223223
let txins = {
224-
let mut ins: Vec<TxIn> = Vec::new();
225-
ins.push(TxIn {
224+
let ins: Vec<TxIn> = vec![TxIn {
226225
previous_output: funding_outpoint,
227226
script_sig: ScriptBuf::new(),
228227
sequence: Sequence::MAX,
229228
witness: Witness::new(),
230-
});
229+
}];
231230
ins
232231
};
233232

@@ -702,8 +701,7 @@ pub(crate) fn make_funding_redeemscript_from_slices(broadcaster_funding_key: &[u
702701
/// Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the
703702
/// commitment transaction).
704703
pub fn build_htlc_transaction(commitment_txid: &Txid, feerate_per_kw: u32, contest_delay: u16, htlc: &HTLCOutputInCommitment, channel_type_features: &ChannelTypeFeatures, broadcaster_delayed_payment_key: &DelayedPaymentKey, revocation_key: &RevocationKey) -> Transaction {
705-
let mut txins: Vec<TxIn> = Vec::new();
706-
txins.push(build_htlc_input(commitment_txid, htlc, channel_type_features));
704+
let txins= vec![build_htlc_input(commitment_txid, htlc, channel_type_features)];
707705

708706
let mut txouts: Vec<TxOut> = Vec::new();
709707
txouts.push(build_htlc_output(
@@ -1590,14 +1588,13 @@ impl CommitmentTransaction {
15901588
commitment_transaction_number_obscure_factor ^ (INITIAL_COMMITMENT_NUMBER - commitment_number);
15911589

15921590
let txins = {
1593-
let mut ins: Vec<TxIn> = Vec::new();
1594-
ins.push(TxIn {
1591+
let ins: Vec<TxIn> = vec![TxIn {
15951592
previous_output: channel_parameters.funding_outpoint(),
15961593
script_sig: ScriptBuf::new(),
15971594
sequence: Sequence(((0x80 as u32) << 8 * 3)
15981595
| ((obscured_commitment_transaction_number >> 3 * 8) as u32)),
15991596
witness: Witness::new(),
1600-
});
1597+
}];
16011598
ins
16021599
};
16031600
(obscured_commitment_transaction_number, txins)

lightning/src/ln/channel.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ impl ChannelState {
610610
}
611611
}
612612

613-
fn to_u32(&self) -> u32 {
613+
fn to_u32(self) -> u32 {
614614
match self {
615615
ChannelState::NegotiatingFunding(flags) => flags.0,
616616
ChannelState::FundingNegotiated => state_flags::FUNDING_NEGOTIATED,
@@ -9505,7 +9505,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
95059505
monitor_pending_forwards,
95069506
monitor_pending_failures,
95079507
monitor_pending_finalized_fulfills: monitor_pending_finalized_fulfills.unwrap(),
9508-
monitor_pending_update_adds: monitor_pending_update_adds.unwrap_or(Vec::new()),
9508+
monitor_pending_update_adds: monitor_pending_update_adds.unwrap_or_default(),
95099509

95109510
signer_pending_revoke_and_ack: false,
95119511
signer_pending_commitment_update: false,

0 commit comments

Comments
 (0)